Removing Gems Errors

Removing Gems errors

USING RVM

1) Install rvm.

In the rest of the steps:

DON'T EVER USE SUDO

2) Install ruby (pick a version):

$ rvm install 1.9.3

3) Make sure rvm's current ruby is the version you want to use for your app :

$ rvm list

and if necessary:

$ rvm use 1.9.3-p194  #Sometimes you have to specify the patch number as well, e.g p194

4) Create a gemset for your app:

$ rvm gemset create myapp_gemset

5) You can list the gemsets for the current ruby version:

$ rvm gemset list

and if necessary switch to the gemset you just created:

$ rvm gemset use myapp_gemset

6) Install the rails gem:

$ gem install rails --version 4.0.0

That command will install the gem into the current gemset. You can check the version:

$ rails -v

There is a shortcut you can use to select the ruby version and a gemset you previously created for that ruby version:

$ rvm use 1.9.3-p194@myapp_gemset

You can also set a default ruby and gemset that will be selected when you open a new terminal window:

$ rvm use 1.9.3-p194@myapp_gemset --default

Or, you can set up your Gemfile in your app so that rvm switches to the specified ruby version and gemset when you change directories into your app's directory:

Gemfile:

ruby '1.9.3'   #(no patch number allowed here)
#ruby-gemset=myapp_gemset

rvm will read that comment in your Gemfile, and then switch to the ruby version on the previous line and the gemset specified in the comment.

.
.

https://rvm.io/gemsets/deleting

Deleting Gemsets

When you delete a gemset, rvm will prompt you to confirm the deletion.

$ rvm gemset use albinochipmunk
$ rvm gemset delete albinochipmunk

To skip confirmation, pass the --force flag:

$ rvm gemset use albinochipmunk
$ rvm --force gemset delete albinochipmunk

By default, rvm deletes gemsets from the currently selected Ruby
interpreter. To delete a gemset from a different interpreter, say
1.9.2, run your command this way:

$ rvm 1.9.2 do gemset delete albinochipmunk

.

If you don't use a gemset at all, you get the gems in the 'default' set

.

https://rvm.io/gemsets/emptying

Emptying Gemsets

If you empty a gemset, rvm will prompt you for
confirmation. This action removes all gems installed in the gemset.

$ rvm gemset use albinochipmunk 
$ rvm gemset empty albinochipmunk

To skip confirmation, pass the --force flag:

$ rvm gemset use albinochipmunk 
$ rvm --force gemset empty albinochipmunk

Uninstalling rails and gems, getting error cannot uninstall, check 'gem list -d ...'

SOLUTION!! I still don't understand why this happened, I'd love if someone could explain. Why was the path non-existant? What caused this error?

Also, I want to mention that the solution I linked to has a comment saying that the question is a duplicate. However, the original has a different solution and did not help me (though its the basis to finding this answer). Simply deleting the gems manually in finder would not remove them from the gem list.

Without further ado - it turns out that when trying to uninstall the gem, it can't locate its path (I think the problem is because of installing with sudo, but I might be wrong). What you need to do is (you have to do this one by one for each gem, or at least I had to):

  1. gem list -d 'name of gem' and note the "Installed at:" location (in my case, /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8)
  2. sudo gem uninstall 'name of gem' -i 'the path noted above' (ex. in my case, sudo gem uninstall rails -i /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  3. Some gems still might not uninstall returning a permissions error. If this is the case, what you need to do is create a folder /bin, in the path above. (in my case, mkdir /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/bin
  4. Continue uninstalling as in step 2, still using the original path (/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8).

Now all uninstalls should work!

Removing all installed Gems and starting over

From the RVM support site:

RVM installs everything into ~/.rvm.
To remove RVM from your system run 'rm
-rf ~/.rvm'. You may have one additional config file in ~/.rvmrc and
of course the RVM hook in your
bash/zsh startup files.

So, just go to the command line and type rm -rf ~/.rvm

All the installed gems are in the ~/.rvm folders, so doing the above will remove the gems and installed rubies in one go.

Gems you added pre-RVM with the default ruby install can be removed by typing this at the command prompt:

for x in `gem list --no-versions`; do gem uninstall $x -a -x -I; done

Uninstalling all gems Ruby 2.0.0

I used this one line script.

for i in `gem list --no-versions`; do gem uninstall -aIx $i; done

It ignores default gem errors and just proceeds. Simple and self-evident.

Bundler: how to remove uninstalled gems

Even though I specified an older version of the gem

No, you didn't.

You specified '~> 2.1', '>= 2.1.4', which means anything 2.1.4 <= version < 3.0.0.

By running bundle update, this installed the latest available version that met your requirements, which was apparently 2.3.5, not 2.1.4.

If you need to also specify a constraint to ruby version 2.3.1, you can also put this in the Gemfile:

ruby '2.3.1'

...And then running bundle update will also take that into consideration when finding the latest compatible dependencies.



I would like to know how to remove pg_search 2.3.5 and install 2.1.4

You don't have version 2.3.5 installed against this ruby version, because it's incompatible.

Apparently you've already installed version 2.1.4.

The problem is that your Gemfile.lock is still expecting version 2.3.5. There are a few ways you could resolve this, but one way or another you need to update the Gemfile.lock to have a compatible set of dependencies with your ruby version.

The simplest approach is probably to just re-run bundle update pg_search, but make sure you're actually using the correct ruby version this time. That should downgrade the dependency, as the newer library version isn't compatible with the older ruby version.

If you still encounter issues, you could take my advice of adding the ruby constraint to the Gemfile, and revert whatever other changes you've recently made that created this incompatible mix of dependencies.



Related Topics



Leave a reply



Submit