ERROR: While executing gem ... (Errno::EISDIR) gem install rails - ruby-on-rails

I'm trying to install Ruby on rails, so first I installed RVM rvm install 1.9.2. After that install this gem install rails. It shows this error
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /var/lib/gems/1.8 directory.
Then I used this sudo chmod 0777 /var/lib/gems/1.8/
After that when I install, its showing this error:
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /var/lib/gems/1.8/cache/railties-3.2.2.gem
Then I run sudo chmod 0777 /var/lib/gems/1.8/cache/railties-3.2.2.gem
After that I install gem install rails. Again its showing this error
ERROR: While executing gem ... (Errno::EISDIR)
Is a directory - /var/lib/gems/1.8/cache/railties-3.2.2.gem

You're still using the system ruby install (1.8). To use the Ruby you've just installed with rvm, do rvm use 1.9.2. Then try gem install rails again. The Rails gem should be installed under your home directory, you shouldn't need root permissions.
To make the rvm Ruby the default, so you always start with it when you open a new terminal, do rvm --default use 1.9.2 (note that's two dashes).

manually install gem-ctags, then retry installing your failing gem
gem install gem-ctags
gem install backports -v '3.3.3'
bundle install

Related

Unable to install rails. error: You don't have write permissions for the /usr/local/rvm/gems/ruby-2.6.3 directory

I installed ruby 2.6.3 using RVM. later when i try to install rails i am getting following error.
$ gem install rails -v 6.0.2.1
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/local/rvm/gems/ruby-2.6.3 directory.
$ sudo gem install rails -v 6.0.2.1
sudo: unable to execute /usr/bin/gem: No such file or directory
That's because at some point you used sudo to install your rvm. So, the system will require sudo permission to install later gems
When you use command $ sudo gem install rails -v 6.0.2.1, you tell system to use normal directly installed ruby, not via rvm, so it warns you No such /user/bin/gem error
The solution for this is to change ownership of all files in the ~/.rvm directory to current account, as if you're using root account by following command
sudo chown -R $USER ~/.rvm

Rails: How to change Bundler default version

bundler (2.0.1, default: 1.17.2)
How could I change the default to 2.0.1
Following https://bundler.io/guides/bundler_2_upgrade.html#upgrading-applications-from-bundler-1-to-bundler-2, here's what worked for me:
gem install --default bundler
gem update --system
bundle update --bundler
What helped me is to delete the current default manually from the folder
lib\ruby\gems\2.6.0\specifications\default\
and then install fresh bundler as usually
gem install bundler
or as default
gem install --default bundler
I had this same concern when trying to setup Bundler gem 2.2.11 as the default gem on my machine.
Here's how I achieved it:
First, I listed and uninstalled all other versions of the Bundler gem because I did not need them:
gem list bundler
gem uninstall bundler
If you encounter an error like this
Gem bundler-2.1.4 cannot be uninstalled because it is a default gem
Simply run the command below to get your ruby installation directory:
gem environment | grep "INSTALLATION DIRECTORY"
This should display an output like this. In my case my ruby version was 2.7.2:
- INSTALLATION DIRECTORY: /home/mycomputer/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0
Next, navigate to the specifications/default directory of the INSTALLATION PATH:
cd /home/mycomputer/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/specifications/default
Remove/delete the bundler.gemspec file that you have there. In my case it was bundler-2.1.4.gemspec, so I ran the command:
rm bundler-2.1.4.gemspec
Next, I installed the Bundler gem 2.2.11 and made it the default gem:
gem install --default bundler -v 2.2.11
Next, I listed my Bundler versions:
gem list bundler
Finally, I updated my gems to use the newly installed Bundler:
gem update --system
That's all.
I hope this helps
You need to remove .spec file to remove the gem.
Steps:
gem env – try to search in provided list under GEM PATHS, in specifications/default
remove there bundler-VERSION.gemspec
install bundler, if you don't have specific: gem install bundler:VERSION --default
gem install --default bundler:<version>
You need to know where the default specs are, so use gem environment to find out.
the steps I used were:
gem environment
# note INSTALLATION DIRECTORY
cd <installation_dir>
cd specifications/default
rm bundler-2.1.4.gemspec
gem install --default bundler -v 2.2.11
Remove all default bundler versions.
Commands:
$ gem environment
$ cd INSTALLATION DIRECTORY
$ cd specifications
$ cd default
$ rm bundler version
$ gem install bundler

Trouble installing Rails 4

I get this error when trying to install Rails 4 after having installed RVM & Ruby 2
MacBook-Pro:~ Jihun$ gem install rails --no-ri --no-rdoc
Fetching: rake-10.1.0.gem (100%)
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
MacBook-Pro:~ Jihun$ rails --version
Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.
Run
rvm use 2.0.0
I think you haven't set it yet. You might have to run
rvm 2.0.0#rails-4.0
instead though to specify rails 4.0 precisely.

Failure to install ruby gems with rbenv

I can't install any Ruby gems. I am using rbenv and when I use gem install rails, I get a permission error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory
I have been trying to install Rails for days now, even with RVM.
I am pretty sure the problem lies with my $PATH but I do not know how to change this.
I am running Ruby version 2.0.0p247.
Can you try gem update --system, and try to gem install again, if it fails, post your log.

bundle install fails with 'ERROR: Gem bundler not installed'

I have bundler-1.1.3 installed. I have an app that I am trying to get to run. but when I do
$cd my_app
$bundle install
the command fails with this error:
ERROR: Gem bundler not installed
I can run bundle install from anywhere else on the sytem, but not within the app folder.
What could be the problem ?
The .rvmrc file in the directory of the app is saying it needs 1.9.2 to run. RVM has a concept of gem sets that are associated with different versions of ruby on your comptuer. You probably don't have the bundler gem installed under your 1.9.2 version of ruby but another version, perhaps 1.8.7 or 1.9.3.
$ cd my_app
$ rvm use 1.9.2
$ gem install bundle
$ bundle install

Resources