After using rails a single use, my rails seem to break. It gives me an error:
/home/username/.rbenv/versions/2.2.3/bin/rails:23:in `load': cannot load such file -- /home/dasith/.rvm/gems/ruby-2.3.0/gems/rails-4.2.6/bin/rails (LoadError)
from /home/dasith/.rbenv/versions/2.2.3/bin/rails:23:in `<main>'
To make it work again, I have to run these commands:
rvm gemset create gemset_name # create a gemset
rvm ruby_version#gemset_name # specify Ruby version and our new gemset
gem install rails -v rails_version # install specific Rails version
Fixed it. It was an permission issue.
sudo chown -R username /home/username/.rbenv
Related
When trying to update OpenSSL - I broke (seemingly) everything surrounding Ruby and Rails on my laptop. Even after uninstalling ruby and rails through gem uninstall and rvm removeI am still running into this error:
Drews-MacBook-Pro:bookstore drewwyatt$ rails server
bin/rails:3: undefined method `require_relative' for main:Object (NoMethodError)
Everything has been working fine for months until I went mucking around - the worse part is that I'm not even sure what I did to mess things up.
extra info
Drews-MacBook-Pro:bookstore drewwyatt$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0]
Drews-MacBook-Pro:bookstore drewwyatt$ which ruby
/Users/drewwyatt/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
Drews-MacBook-Pro:bookstore drewwyatt$ rails -v
bin/rails:3: undefined method `require_relative' for main:Object (NoMethodError)
Drews-MacBook-Pro:bookstore drewwyatt$ which rails
/Users/drewwyatt/.rvm/rubies/ruby-2.0.0-p247/bin/rails
Drews-MacBook-Pro:bookstore drewwyatt$
update - installing without sudo
Drews-MacBook-Pro:~ drewwyatt$ gem install rails
Fetching: railties-4.0.0.gem (100%)
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Users/drewwyatt/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks
Drews-MacBook-Pro:~ drewwyatt$
I fixed the problem by completely removing Rails, Ruby, and RVM altogether - then starting from scratch.
I don't remember all of the commands exactly, but it was something like:
sudo gem uninstall rails
sudo rvm remove 2.0
rvm implode
sudo chown -R drewwyatt: ~/.rvm/
rm -rf ~/.rvm
\curl -L https://get.rvm.io | bash -s stable --rails
rvm use 2.0
gem install rails
This came up for me after installing rails with Rails Composer. Seems like a problem with RVM selecting the ruby version, the trick was to simply navigate out and back into the folder.
$ cd ..
$ cd myapp
I was able to resolve this problem by simply running gem install rails.
This problem occurred when I cloned a pre-existing Rails 4 app. I am using ruby-2.0.0-p317, and an RVM gemset specific to this app. I ran the initial bundle install, but then could not run rails console without getting the error.
After running gem install rails, which used the cached copy in my app's gemset, the problem was resolved. Don't ask my why!
Try running bundle exec rails server instead of just rails server.
I was seeing this error because I had a conflicting version of the rails gem installed globally.
Prefixing commands with bundle exec ensures that you're using gems specified by your project's Gemfile.lock.
Similar to #ncherro, I got this using ruby filename.rb. Running
bundle exec ruby filename.rb
works.
When I use rvm use 1.9.2, I get Rails v3.0.0:
vikas#admin1-DL-H61MXEL:~$ rvm use 1.9.2 --default
Using /home/vikas/.rvm/gems/ruby-1.9.2-p320
vikas#admin1-DL-H61MXEL:~$ rails -v
Rails 3.0.0
When I use rvm use 2.0.0, I get Rails v3.2.13:
vikas#admin1-DL-H61MXEL:~$ rvm use 2.0.0
Using /home/vikas/.rvm/gems/ruby-2.0.0-p195
vikas#admin1-DL-H61MXEL:~$ rails -v
Rails 3.2.13
I need Rails v3.2.13 with Ruby 1.9.2.
When I used rvm use 1.9.2 --default and gem install rails -v 3.2.13, I got the following error:
While executing gem ... (Gem::FilePermissionError) You don't have write permissions into the /home/vikas/.rvm/gems/ruby-1.9.2-p320/bin directory.
This is the error I'm facing now.
The most likely reason you're getting the error:
(Gem::FilePermissionError) You don't have write permissions into the /home/vikas/.rvm/gems/ruby-1.9.2-p320/bin directory.
Is because, at some point, you used sudo or were running as root when you use RVM to install a gem. When that happened, the ownership of files and/or folders changed to root's permissions, which you can't override running as you.
You don't want to run as root, or use sudo EVER when running rvm or gem commands if you have a RVM installation to provide Ruby in a sandbox in your home directory.
To fix this, try this command:
sudo chown -R vikas ~/.rvm
That will use sudo to change ownership of all files in the ~/.rvm directory to your own account, from the "root" user. This will take at least a few seconds so let it run.
Once that has run, you should be able to switch to each of your Rubies and delete the installed Rails:
rvm use 1.9.2
gem uninstall rails
gem install rails -v 3.2.13
Then:
rvm use 2.0.0
gem uninstall rails
gem install rails -v [whatever version you want]
gem install rails -v
rvm use 1.9.2 --default Using /home/vikas/.rvm/gems/ruby-1.9.2-p320
gem install rails -v 3.2.13
rvm is software tool by which you can manage multiple version of rubies on your system.
for each ruby version you can create a gemset which is just a group of gems.
each ruby version you install has a 'default' gemset.
and it seems that you have installed rails 3.0 for ruby 1.9.2 and rails 3.2.13 for ruby 2.0
you can create your own gemset by command
rvm gemset create rails3
this will create a gemset named 'rails3' and to use it you have to do
rvm gemset use rails3
and in this gemset you can install any version of rails you want.
with command
gem install rails -v='3.2.13'
for more info see rvm doc.
https://rvm.io/
I have rails and RVM installed on OSx 10.7.4
If I do this
$ cd ~/
$ rails -v
I get
$ Rails 3.2.3
Now if I go into a rails application with
$ cd ~/rails-project/
Using ~/.rvm/gems/ruby-1.9.2-p320 with gemset ourgemset
The .vmrc file in the rails app looks like this
rvm use --create 1.9.2#ourgemset
However when I try and use rails now I get
$ rails -v
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.
My ~/.bash_profile has this line at the end of it (and these scripts exist)
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
I've no idea why this is happening or where to look to solve it.
EDIT:
On further investigation if I do the following
$ rvm use default
Using ~/.rvm/gems/ruby-1.9.3-p194 with gemset anothergemset
Now rails works fine. If I switch back to
$rvm use ruby-1.9.2-p320
I can't use rails anymore. Help!
Your global env has Rails but your gemset does not contain the rails gem. So when you are in cd ~/rails-project/ run the command:
gem install rails
it will install the gem to your rvm gemset.
I'm on Ubuntu 11
Tring to install rails 3.1
It seems like I install rails but then I can't use it.
I want to use rvm to install and use rails and I do not want to go the sudo apt-get route.
Thanks!
durrantm#castleLinux2011:~$ rvm list rubies
rvm rubies
ruby-1.9.2-p290 [ x86_64 ]
durrantm#castleLinux2011:~$ rvm use --create 1.9.2#rails3
Using /home/durrantm/.rvm/gems/ruby-1.9.2-p290 with gemset rails3
durrantm#castleLinux2011:~$ rvm list rubies
rvm rubies
=> ruby-1.9.2-p290 [ x86_64 ]
durrantm#castleLinux2011:~$ gem install rails
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
durrantm#castleLinux2011:~$ sudo gem install rails
Successfully installed rails-3.1.0
1 gem installed
Installing ri documentation for rails-3.1.0...
file 'lib' not found
Installing RDoc documentation for rails-3.1.0...
file 'lib' not found
durrantm#castleLinux2011:~$ rails
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
durrantm#castleLinux2011:~$
btw
durrantm#castleLinux2011:~$ gem install rails
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
durrantm#castleLinux2011:~$
doesn't work either and I have danced around the zlib issue for about an hour.
Also:
rvm gemset install rails
installing rails ...
ERROR: Error running 'GEM_HOME='/home/durrantm/.rvm/gems/ruby-1.9.2-p290#rails3' GEM_PATH='/home/durrantm/.rvm/gems/ruby-1.9.2-p290#rails3' gem install rails ', please read /home/durrantm/.rvm/log/ruby-1.9.2-p290/gem.install.log
rails failed to install ( output logged to: /home/durrantm/.rvm/log/ruby-1.9.2-p290/gem.install.log )
durrantm#castleLinux2011:~$ tail -20 /home/durrantm/.rvm/log/ruby-1.9.2-p290/gem.install.log
[2011-09-13 09:17:57] GEM_HOME='/home/durrantm/.rvm/gems/ruby-1.9.2-p290#rails3' GEM_PATH='/home/durrantm/.rvm/gems/ruby-1.9.2-p290#rails3' gem install rails
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
durrantm#castleLinux2011:~$
no no, no rvmsudo.
rvm pkg install zlib && rvm install 1.9.2 (so it builds against that zlib that rvm installed) && rvm --create use 1.9.2#rails31 (to create a rails31 gemset and use it all on one go)
NOTE: use rvm install 1.9.2 if you used that to install originally. the -p290 shows up because it is a result of the fact that the ruby project has 290 as the official release and rvm picks up on that. This way with 1.9.2 and not 1.9.2-p290 when 1.9.2 series is jumped, rvm will pick up on that and install that instead. Otherwise if you originally did 'rvm install 1.9.2-p290' then do that instead.
As for the rails command. If you executed the above commands then you have been moved into the right rvm controlled ruby and gemset. If not then execute that command now (rvm --create use 1.9.2#rails31)
NOW you can execute gem install rails -v='3.1.0' (I added the version just in case rails changes before you see this)
This will install the rails gem and its deps into Ruby 1.9.2-p290's rails31 gemset. Now you can execute rails new test_app to test it. (I usually mkdir -p $HOME/tmp && cd $HOME/tmp && rails new test_app)
This should eliminate your problems.
You need to reinstall ruby. Follow the instructions in http://beginrescueend.com/packages/zlib/.
You might get the same problem with readline or openSSL, check the rvm website as they provide some workarounds for those libraries too.
I try command bundle install --local
but it show issue:
-bash: /usr/local/bin/bundle: /usr/local/bin/ruby: bad interpreter: No such file or directory.
please help me.
The solution that worked for me was entirely different, perhaps because I've been inconsistent about using RVM or not.
I used 'which bundler' to find out where bundler was being launched, it was from /usr/bin/bundler. Noticing that /usr/bin/bundler began with a location and version of ruby that did not exist on my system any more, I did
gem uninstall bundler
gem install bundler
Checking 'which bundler' again confirmed that bundler was now installed within a .rvm environment instead of /usr/bin/bundler, and now references the correct version of ruby; so bundle install now works for my rails project.
I think you need to export the path of ruby and bundle in your .bashrc (linux).
Open your .bashrc and add this line:
export PATH="$PATH:/usr/bin:/usr/local/bin/"
It should work.
The bundle executable is provided by the bundler gem. If you are using rvm then seeing which bundle in /usr/local/bin/bundle indicates a problem, because use of rvm means gems like bundler are installed under your home directory, usually in ~/.rvm/gems/....
# Symptoms of a broken bundler installation:-
# Cannot start Rails...
$ bin/rails s
/Users/rogermarlow/project/config/boot.rb:9:in 'rescue in <top (required)>': uninitialized constant Bundler (NameError)
# bundle not working...
$ bundle install
zsh: /usr/local/bin/bundle: bad interpreter: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin: no such file or directory
# ^----- that path does not look right, rvm does not put gems there
$ which bundle
/usr/local/bin/bundle
# ^--- I want bundle from something under ~/.rvm/gems
# First check rvm is in effect:
$ rvm reload
RVM reloaded!
$ which ruby
/Users/rogermarlow/.rvm/rubies/ruby-2.3.4/bin/ruby
# ^--looks good, it is an rvm path, not /usr/local/bin/...
# Now fix bundler
$ gem uninstall bundler # just in case
$ gem install bundler
Fetching: bundler-1.16.1.gem (100%)
Successfully installed bundler-1.16.1
1 gem installed
$ which bundle
/Users/rogermarlow/.rvm/gems/ruby-2.3.4#project/bin/bundle
$ ^--- that is better, bundle is on a path controlled by rvm
# bundle now working
$ bundle install
Fetching gem metadata from http://rubygems.org/..........
*snip*
# rails now working
$ bin/rails s
=> Booting Thin
=> Rails 4.2.7.1 application starting in development on http://localhost:3000
*snip*
On my side, I am using rbenv.
When I checked the /usr/local/bin/bundle, it shows it is using the older ruby, thus causing the problem.
#!/usr/bin/ruby1.9.1
by changing it to point to proper ruby fix the problem
#!/home/user/.rbenv/shims/ruby
For newly created gem-set gem bundler is missing for me,
Before bundler install path for it, /usr/local/bin/bundler
Installed bundler to resolve issue.
gem install bundler --no-ri --no-rdoc
Bundler path changes to, /home/root/.rvm/gems/ruby-2.2.1#drag-drop-list/bin/bundler
Encountering this same problem,
I found bundler installation in /var/lib/gems/2.3.0/gems/bundler-1.16.1;
Then i fixed the error by creating a symbolic link like this:
ln -s /var/lib/gems/2.3.0/gems/bundler-1.16.1/
/usr/lib/ruby/gems/2.3.0/gems/bundler-1.16.1
I did this because I needed this version of ruby.