Why won't this gem be uninstalled - ruby

i installed a gem from this repository using this in my Gemfile :
gem 'copy_carrierwave_file', github: 'equivalent/copy_carrierwave_file'
when i'm trying to uninstall it using :
gem uninstall copy_carrierwave_file
nothing is shown like copy_carrierwave is uninstalled successfuly from....
then if i type :
bundle show copy_carrierwave_file
it still show me the location of this gem
How i can uninstall it ?

Since git, github, and path located, or development gems are controlled by bunlder, you have just to remove put to delete gem from Gemfile. And you even don't need to run bundle install again.
$ bundle show session
Could not find gem 'session'.

Bundle Clean. Since the gems were installed using bundler, they have to be uninstalled using bundler too!
First, remove the line gem 'copy_carrierwave_file', github: 'equivalent/copy_carrierwave_file' from your Gemfile
Then, bundle clean with dry-run (just in case you see gems you don't want to remove):
bundle clean --force --dry-run
If you want to remove those gems, clean it:
bundle clean --force

Related

Bundler: install gems from git to gems folder instead of bundler folder

The inside of your "Gem Path" (see: $ bundle env) contains a gems and a bundler folder. The gems folder is populated by gems installed e.g. via gem install or the gem tag of a Gemfile. The bundler folder, on the other hand, holds for example gems installed via the git feature of a Gemfile:
gem 'my-gem', git: "https://github.com/x/y.git"
I assume this is so that custom installations don't conflict with installations from a gem server. Nevertheless, I'd like to treat a specific gem installed from git as if it's coming from a gem server.
Is it possible in this case to tell bundler to use the gems folder instead?
My current workaround is to clone the repo and then build and install the gem locally.
I've also looked at Gem::SpecificInstall which might solve this issue (although not through bundler) but it doesn't support authentication for private repos which is a dealbreaker for me.

How do I force Bundler to reinstall all of my gems?

How do I force Bundler to reinstall all of the gems in my gemfile? Or, how do I force Bundler to uninstall all of the gems it installed so I can then reinstall them myself?
I saw rails bundle clean, but this question explains how to remove gems that bundle installed but are no longer in the gemfile.
And How to reinstall a gem using bundler explains how to reinstall a single gem. I would like to reinstall all of my gems at once.
bundle install --redownload
See the reference for bundle install: https://bundler.io/v2.2/man/bundle-install.1.html
or
bundle install --force
For older versions of bundler
Brutish but clever:
Comment out your entire Gemfile. (Don't delete it)
bundle clean
Restore your Gemfile.
bundle install
You can also delete the vendor directory and do bundle install again.
If you completely want to reinstall everything from scratch you can just, locate your gem dir, for example if you use rvm it would be ~/.rvm/gems
then locate your ruby version alongside with gemset for example ruby-2.7.0#some_particular_gemset (it will be a dir) and then just delete it.
rm -rf ruby-2.7.0#some_particular_gemset
bundle install
Another way to deal with gem problems can be to sudo gem clean instead of reinstalling everything

Bundler install custom path issue

gem env shows
GEM PATHS:
/usr/local/share/gems
I would like to use bundle install --deployment --path=/usr/local/share/gems to install my bundled gems.
The problem is that the bundle install creates a folder ruby and puts the gems folder inside the ruby folder.
When this happens my ruby code is unable to find the gems in its default path.
Looks like I am missing some configuration parameter. Help please.
MaurĂ­cio Linhares comments in the question has resolved the issue.
When using bundler to install gems use bundle exec ruby. When the bundle install --deployment happens the path information goes into .bundle/config
bundle exec ruby path-to-ruby-script.rb
The above execution Will find the gems installed by the bundle command.
Alternatively, if you want to force installation to the system gem location, I believe bundle install --deployment --system will do what you want.

'Undo-ing' changes to Gem source

I was debugging a gem a while ago and accidentally left in some code that causes my project to hang when it makes use of that gem. How can I restore the clean source? Is the only option to uninstall and reinstall?
The command
gem pristine foo
Does this for the gem of that name. You can also pass --all to rebuild all gems. This works by comparing what's in the .gem file (which is a tar archive in disguise) with the actual files. More details in the documentation
Uninstall that gem with gem uninstall <gem_name> and then reinstall via gem install <gem_name> or bundle install.

Why 'bundle install' need these files to be pre-installed?

Here's what I tried:
gem install testgen
success
gem install bundlesuccess
go to project root created using testgen
bundle install this failed and asked to install gem install i18n -v '0.6.11' So I added it in gemfile this way gem 'i18n', '>=0.6.11' and tried bundle install again but it gave same error again. So I had to install it manually without using bundle install
Once this is completed it asked for many other files.
Question is: If I had to install gems manually one by one what's the use of bundle install then?
and
Why it was not installing the required gem when it is specified in Gemfile?
The command bundle install goes through every gem in the Gemfile and installs it, along with all dependencies.
An error like yours means that one of the gems, or one of its dependencies, failed to install. The Gemfile is already referencing the failing gem; you don't need to reference it again. Instead, try it from the command line:
gem install i18n -v '0.6.11'
This might fail, but the error will be more useful. This process isn't 'installing gems manually', it is solving problems your computer is raising with certain pieces of software. Bundler can't work through every problem on every kind of machine on its own.
Check out http://bundler.io/, it has some great docs that should help clarify.

Resources