I have a Middleman project in an Ubuntu 14.04 machine and I just want to run bundle exec middleman build using a per-project ruby version. So in the root folder of the project I have a .ruby-version with this content: ruby-2.2.0.
rvm list shows
rvm rubies
* ruby-1.9.3-p551 [ x86_64 ]
ruby-2.1.4 [ x86_64 ]
=> ruby-2.2.0 [ x86_64 ]
Which seems fine. But ruby -v shows ruby 1.9.3p484 and that middleman command fails because it uses the wrong ruby version
$ bundle exec middleman build
bash: /usr/local/bin/bundle: /usr/bin/ruby1.8: bad interpreter: No such file or directory
So, how can I make sure that middleman uses the ruby version defined in the project folder ?
Your rvm is using ruby version -1.9.3 . You have to type rvm --default use 2.2.0 and after that you can check the active version of ruby by typing rvm list
If there is a * sign near the ruby version 2.2.0 then it is using it for default usage . And I hope you will be able to fix this problem.
Related
I am trying to use the prawn gem. I am just trying out the basic hello world example, on an ubuntu machine.
require 'prawn'
Prawn::Document.generate("hello.pdf") do
text "Hello World!"
end
First problem was that I was using ruby 1.9.1, it produced an error and said it needed ruby 2.0, so using RVM I updated to 2.2.1. However everytime I run this, I get this error
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require': cannot
load such file -- prawn (LoadError) from
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:inrequire' from
prawnpdf.rb:1:in `'
Now I am bit a newbie with Ubuntu and ruby for that matter, but I assume the issue is that it is looking in the wrong place for the prawn gem which I have installed ie it is looking in the old verison of ruby.
When I run $ ruby -v
I get
ruby 2.2.1p85 (2015-02-26 revision 49769) [i686-linux]
what am I doing wrong? any help would be most appreicated.
Follow the given step.
1: rvm list
rvm rubies
ruby-2.0.0-p643 [ x86_64 ]
ruby-2.2.1 [ x86_64 ]
=* ruby-2.2.4 [ x86_64 ]
2: rvm use < ruby-version > # for instances ruby-1.9.3-p125
rvm use 2.2.1
3: gem install prawn
Would work !!!
Each time you switch ruby versions with rvm, you start using a new gemset. Having previously installed prawn doesn't mean it is currently installed, and the error message suggests it's not installed. So:
rvm use 2.2.1
and then
gem install prawn
Then your code should work.
I suggest you create a Gemfile for your project so it becomes easier to maintain the dependencies.
See details: http://bundler.io/
Then cd into your project directory and install the bundle (once or after changes) and run your ruby script:
cd my_project
bundle install
ruby my_thing.rb
If you cannot/don't want to use bundler: you need to reinstall the Gem for every ruby.
I am trying to install Jekyll in a VM for my web course and it required ruby >= 2.0.0.
I've gone through installing RVM and using this to install the desired version of ruby, but I then get the following:
vagrant#precise32:~/.rvm/bin$ bash rvm list
rvm rubies
ruby-2.1.1 [ i686 ]
=* ruby-2.2.1 [ i686 ]
# => - current
# =* - current && default
# * - default
vagrant#precise32:~/.rvm/bin$ ruby -v
ruby 1.8.7 (2011-06-30
patchlevel 352) [i686-linux]
vagrant#precise32:~/.rvm/bin$ sudo gem
install jekyll ERROR: Error installing jekyll:jekyll requires Ruby version >= 2.0.0.
vagrant#precise32:~/.rvm/bin
I don't understand why it still thinks it is using version 1.8.7, as it confirms that it has installed 2.2.1.
I have done the following:
Use sudo chown to change ownership of the .gnupg folder recursively to vagrant (my system user) as defined here.
Install RVM following the instructions here.
Installed the version (2.2.1) of ruby using these instructions (https://rvm.io/rubies/installing).
Tried to install Jekyll using sudo gem install jekyll, but I get an error saying that I need ruby version 2.0 or higher.
I'm not a developer, this is an introductory web development course. Also please excuse the corrupt link, I can't post more than 2.
Update: I think I might need to do something as described here: How do I change my Ruby version using RVM?.
Also - although I installed RVM, I originally installed it using sudo apt-get which corrupted it. I uninstalled that, and ran the most recent install with curl. To use it I have to navigate to the directory and use "bash rvm list"
Add following two lines:
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
to your $HOME/.profile file and restart a shell.
It seems your machine is using Its own instead by RVM.
1: rvm list # Listing install rubies will you get versions of ruby which is installed by RVM
2: rvm use < ruby-version > # for instances ruby-1.9.3-p125
3: bundle install
4: Tried to install Jekyll using sudo gem install jekyll, but I get an
error saying that I need ruby version 2.0 or higher.
For that you could try Installing Jekyll on Ubuntu 14.04
Hope this help you !!!
I'm getting the following bug when I run rails c:
Your Ruby version is 2.1.2, but your Gemfile specified 2.2.2
When I run $rvm list rubies, I get the following:
rvm rubies
=* ruby-2.2.2 [ x86_64 ]
I am confused. I tried to change the Ruby version in the Gemfile to 2.1.2 and install ruby-2.1.2. However I still get:
Your Ruby version is 2.2.2, but your Gemfile specified 2.1.2
Any suggestions?
Please install ruby-2.2.2 on your system then do either one of these:
1. rvm use ruby-2.2.2
2. create a .ruby-version file inside your application root folder with the following content:
2.2.2
Try this:
$ rm Gemfile.lock
$ bundle
Neither answer worked for me, and I already had 2.2.2 installed and specified in .ruby-version. What worked for me was
rvm use 2.1.2
rvm use 2.2.2
and then everything works fine. I suspect that rvm was somehow confused.
Declaration: In reality, I had this problem with swapping between 2.5.9 and 2.7.3.
I want to install the compass html5 boilerplate gem. When I try to install it I get the following error.
$ sudo gem install html5-boilerplate
ERROR: Error installing html5-boilerplate:
compass-h5bp requires Ruby version ~> 2.0.
Then when I check my ruby version it says:
$ ruby -v
ruby 1.9.3p484 (2013-11-22 revision 43786) [x86_64-linux]
But I used RVM before so I thought I could just change version but when I check it says I'm using ruby-2.2.0 already.
$ rvm list
rvm rubies
=* ruby-2.2.0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
I think I must be missing something obhvious, it's been a while since I've worked with Ruby and RVM.
Update 1
I ran the below commands as suggested by #tadman and it does seem the wrong path is being used.
~:$ cd ~/.rvm/bin
bin:$ ls
ruby-rvm-env rvm rvm-auto-ruby rvm-exec rvm-prompt rvm-shebang-ruby rvm-shell rvm-smile rvmsudo
bin:$ which ruby
/usr/bin/ruby
UPDATE 2
After correcting the path in my .bash_profile the ruby version seems correct but I'm still getting the same error when trying to install the html5-boilerplate gem??
$ sudo gem install html5-boilerplate
ERROR: Error installing html5-boilerplate:
compass-h5bp requires Ruby version ~> 2.0.
$ ruby -v
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
$ rvm list
rvm rubies
=* ruby-2.2.0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
$ compass -v
Compass 1.0.3 (Polaris)
Copyright (c) 2008-2015 Chris Eppstein
Released under the MIT License.
Compass is charityware.
Please make a tax deductable donation for a worthy cause: http://umdf.org/compass
Also i have the compass gem installed on both Ruby 1.9.1 and RVM's ruby 2.2.0. Could this have something to do with it?
$ pwd
/var/lib/gems/1.9.1/gems/compass-1.0.3
$ cd /home/ross/.rvm/gems/ruby-2.2.0/gems/compass-1.0.3
$ pwd
/home/ross/.rvm/gems/ruby-2.2.0/gems/compass-1.0.3
Is there a way to check which ruby version compass is using?
Having RVM and having RVM installed correctly are two different things. The most common cause of a mismatch like this is that your system Ruby has priority in your PATH.
In a POSIX shell, which ruby will tell you which one is getting executed. It is probably the wrong one.
RVM does its magic by manipulating which Ruby shows up in the RVM bin path, often ~/.rvm/bin or something similar. To get it to work correctly you'll need to ensure that path is first in your $PATH.
You may want to try reinstalling the RVM stub, or check that it's correctly loaded into your environment.
Bundle fails to install better_errors.
Gem::InstallError: better_errors requires Ruby version >= 2.0.0.
An error occurred while installing better_errors (2.0.0), and Bundler cannot continue.
Make sure that `gem install better_errors -v '2.0.0'` succeeds before bundling.
But gem install better_errors works fine.
ruby --version says ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux-gnu]. I already tried upgrading to 2.1 but still not working.
Any suggestions?
I had this same problem. In my case, the bundler script had
#!/usr/bin/ruby
as the initial line in the script. As a result, it was calling the system (non-rbenv) version, which was 1.9.1 (in Linux Mint)
It's pretty hacky but changing that first line by running
sudo nano /usr/local/bin/bundle
to the full path for the rbenv shim (in my case):
#!/home/$YOUR_USERNAME/.rbenv/shims/ruby
solved the problem.
Hi for all the people who have different versions of ruby in their machine, and even if
rvm use ruby-version doesn't work.
Try this,
rvm list this will specify all the ruby version in your machine.
rvm rubies
* ruby-1.9.3-p484 [ x86_64 ]
ruby-2.1.0-preview2 [ x86_64 ]
ruby-2.1.1 [ x86_64 ]
=> ruby-2.1.5 [ x86_64 ]
In your project root folder, just create a file
.ruby-version
and add the ruby version you are planning to use.
ruby-2.1.5
Thats it, restart your application and try reinstalling your gems. :)
If you use rvm, make sure you don't have an .rvmrc file at the root of your project that force ruby < 2.0 to run, same with rbenv and .ruby-version file