I've been working on a rails project in sublime text and switched to rubymine. It said that some gems, which are required in the project, are not installed. Well, I tried to install them, but it fails with an error saying that the used ruby version is another than the version specified in the gem file.
When I enter ruby -v, it looked like the same version. I've then tried to reinstall the ruby version (2.0.0) and as that didn't lead to success, I've installed 2.1.0 hoping it would set the correct path and everything.
When I now try to enter bundle, I get the following error:
bash: /Users/user/.rvm/gems/ruby-2.0.0-p353/bin/bundle: /Users/user/.rvm/rubies/ruby-2.1.0/bin/ruby: bad interpreter: No such file or directory
Version 2.1.0 is not even installed anymore.
I've searched for solutions for a long time but nothing really worked in my case. How would you fix this error? As far as I understand I understand the problem and the answers I've read, some kind of link to a path, used by the bundle command, is set wrong?
I'm using rvm for ruby the versions.
ruby -v says `ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin12.5.0]
rvm listsays
ruby-1.9.2-p320 [ x86_64 ]
ruby-1.9.3-p0 [ x86_64 ]
ruby-1.9.3-p392 [ x86_64 ]
ruby-1.9.3-p448 [ x86_64 ]
ruby-2.0.0-p0 [ x86_64 ]
ruby-2.0.0-p247 [ x86_64 ]
=* ruby-2.0.0-p353 [ x86_64 ]
You should run:
gem install bundler
after reinstalling ruby and point of note, your version of ruby should be same as that in the Gemfile
For me the problem was happening because I had installed 2 versions of Ruby, and after deleted one of them. The console was trying to get the deleted version of ruby.
The solution was:
Remove the old version from the environment vars.
Observation: I'm using Windows 10.
Related
I had used ruby version manager (rvm) to install a new version of ruby. Running the command rvm rubiesshows all the version of rubies that are installed. The list is given below.
rvm rubies
ruby-1.9.3-p551 [ x86_64 ]
ruby-2.1.5 [ x86_64 ]
ruby-2.2.4 [ x86_64 ]
* ruby-2.3.0 [ x86_64 ]
ruby-2.3.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
I tried to run the command bundle exec rake rb:mgirate and I get the following error.
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs': Could not find 'bundler' (>= 0.a) among 5 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=:/nix/.nix-profile/lib/ruby/gems', execute `gem env` for more information
The error states that bundler isn't installed. I ran the command gem install bundle and I get the following error.
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /nix/.nix-profile/lib/ruby/gems directory.
It says that I don't have write permissions. I googled the error and it has something to do with updating ruby and ruby version. The reason why I updated to a new ruby version was because heroku run rake db:seed wasn't seeding data in production. I though it might be due to compatibility issues. Therefore, I decided to update to the new version of ruby. The servers, postgresql and everything else works fine. I can't run bundle because I can't install the gem. Any hep would be greatly appreciated. Thanks!
The problem was fixed by switching to the ruby version 2.3.0 by running the command rvm user 2.3.0. Once that is done you should restart the workspace. The reason for the error was the fact that when you switch ruby version it also changes gem files. Therefore, it wasn't able to recognize the gems.
hey just add "sudo" at the beginning of your command. It will definitely work, because as the error says you don't have write permission. And if you will check the permission of that directory than you will find that only owner has write permission and as sudo takes us to the owner mode from user mode. Hence you will not get this error again. Please let me know if it doesn't works.
I have this
# Gemfile
source 'https://rubygems.org'
ruby '2.1.5'
and
#.ruby-version
2.1.5
and this
$ rvm list
rvm rubies
ruby-1.9.3-p484 [ x86_64 ]
ruby-2.0.0-p451 [ x86_64 ]
ruby-2.1.0 [ x86_64 ]
ruby-2.1.1 [ x86_64 ]
ruby-2.1.2 [ x86_64 ]
ruby-2.1.3 [ x86_64 ]
* ruby-2.1.5 [ x86_64 ]
And yet I keep getting this:
$ rails s
Your Ruby version is 2.1.2, but your Gemfile specified 2.1.5
Ruby 2.1.5 is installed.
Already installed ruby-2.1.5.
To reinstall use:
rvm reinstall ruby-2.1.5
ruby - v
ruby 2.1.2p95
$ rvm use --default 2.1.5
Using /home/alex/.rvm/gems/ruby-2.1.5
But then when I open a new tab or terminal, it reverts back to 2.1.2
ruby - v
ruby 2.1.2p95
If you want to use the ruby version just for now , you can choose it by
rvm use 2.1.5
And if you want to always be on that version of ruby just type
rvm --default use 2.1.5
Your error clearly indicate that you do have another method in your code which setting default ruby-2.1.2 also.
There must be some other file than .ruby-version which setting your default ruby version. Due to which your .ruby-version file not setting default version for you nor your Gemfile.
Look into your application root directory and try find hidden file like .rvmrc or .ruby-version or similar try update or delete that file and then run rails s.
After update or delete don't forgot to reopen your application directory. (cd .. and cd /app_directory) Otherwise it won't affect changes.
All of the sudden, Rails' console stopped working on one of my projects. I keep getting the following error:
rails c
Warning: You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
Could not find activesupport-4.1.4 in any of the sources
Run `bundle install` to install missing gems.
So I updated Rubygems, with the following two lines (from rubygems.com)
$ gem install rubygems-update # again, might need to be admin/root
$ update_rubygems
and get the following output:
Successfully installed rubygems-update-2.4.4
Parsing documentation for rubygems-update-2.4.4
Done installing documentation for rubygems-update after 0 seconds
1 gem installed
...
RubyGems 2.4.4 installed
Parsing documentation for rubygems-2.4.4
Installing ri documentation for rubygems-2.4.4
=== 2.4.4 / 2014-11-12
Aaaaaand, then I run rails console again, and just get the same error message again.
Thoughts?
This might be the problem only if you use rvm else just ignore it.
Navigate to the root path (where your rails app is located).
type in your command line;
rvm list
You will get something like:
rvm rubies
jruby-1.7.11 [ x86_64 ]
ruby-2.0.0-p247 [ x86_64 ]
=* ruby-2.0.0-p451 [ x86_64 ]
ruby-2.1.0 [ x86_64 ]
ruby-2.1.1 [ x86_64 ]
# => - current
# =* - current && default
# * - default
If your default is not the current you have most likely changed it.
Try to change it back and run:
You can change it like so:
rvm use ruby-2.0.0-p451
When you get the right version you can make it permanent.
like so:
rvm --default use ruby-2.0.0-p451
bundle install
again.
Just a shot in the dark, but maybe try:
gem install activesupport -v 4.1.4
Then try and run rails c again.
The message also says to run gem pristine --all which will reinstall all the gems from the cache and recompile all native drivers in the gems.
Updating the Rubygems code doesn't do this so you have to explicitly run the command.
RVM won't let me run bundle because it thinks my Ruby version is different from what my Gemfile says, but it isn't:
$ rvm list
rvm rubies
=> ruby-1.9.3-p194 [ x86_64 ]
ruby-1.9.3-p429 [ x86_64 ]
* ruby-2.0.0-p195 [ x86_64 ]
# => - current
# =* - current && default
# * - default
$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin13.0.0]
Gemfile:
ruby '1.9.3-p194'
But then:
$ bundle install
Your Ruby version is 1.9.3, but your Gemfile specified 1.9.3-p194
$
This seems like a very strange thing. Any ideas? There are a lot of people who have this question, but their Gemfiles are obviously different from the running version. I've even done rvm use 1.9.3-p194 and then immediately after bundle install but I get the same error. bundle update produces the same error.
If I remove the ruby version from the Gemfile, it will default to 2.0.0 but switching by rvm use to the proper version (to comply with remote server ruby version) actually works. Running bundle install then works.
Could this error come from also having an rvmrc file (even though specifies the same ruby version) in the Rails project as well?
The ruby directive explicitly leaves out the ability to specify a
patch level. Ruby patches often include important bug and security
fixes and are extremely compatible.
http://bundler.io/v1.2/gemfile_ruby.html
The entry in your Gemfile should simply be ruby '1.9.3'
Remove the line and add a file named '.ruby-version' with '1.9.3-p194' in it. The .ruby-version approach is compatible with several ruby managers beyond rvm.
After installing RVM, I have installed Ruby 1.8.7 then Rails 3.
When I do which rails I get /Users/davidbenhamou/.rvm/gems/ruby-1.8.7-p302/bin/rails.
But when I do rails -v I get -bash: /usr/bin/rails: No such file or directory
Why is Rails not working?
Note: I have followed all steps from RVM website and Ruby command line work fine (ruby -v).
To see the rubies you have installed:
rvm list rubies
And you'll see something like this:
ree-1.8.7-2011.03 [ i686 ]
* ruby-1.9.2-p290 [ x86_64 ]
ruby-1.9.3-p0 [ x86_64 ]
=> ruby-1.9.3-p125 [ x86_64 ]
ruby-1.9.3-p125-perf [ x86_64 ]
To use a specific one:
rvm use ruby-1.9.3-p125
then if you do ruby --version, you'll see:
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin10.7.0]
In each of these rubies you need to install all the gems you want to use. The way I do it is actually by using Bundler to install all the gems for a project. But for the simple case here, just do:
rvm all do gem install rails
This will install the rails gem in all your ruby versions. To install to a particular one, use:
rvm ruby-1.9.3-p125 do gem install rails
after you installed RVM and after you set the default Ruby version in RVM, you need to re-install all ruby gems, e.g.
gem install rails
you need to install those gems as the user, not as root.
Because from now on RVM will keep track of all installed gems by the ruby version which was used to install them!