The command bundle exec jekyll serve stopped to work correctly on my system, and leads now to this error:
bash: /usr/local/bin/bundle: /usr/bin/ruby2.5: bad interpreter: No such file or directory
I don't know how it happened, but gem tells me that jekyll and bundle are not installed, when actually they are present in a different path:
$ which gem
/usr/bin/gem
$ which ruby
/usr/bin/ruby
$ which bundler
/usr/local/bin/bundler
$ which jekyll
/usr/local/bin/jekyll
$ lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
$ gem --version
3.1.2
$ ruby --version
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
I don't know how to undo that. I looked around and there are several ways to repair this (export a path, reinstall ruby), but I'm unsure which way is the less likely to break my system more.
Related
I successfully installed ruby version to 2.7, but ruby -v doesn't want to update. See output below:
➜ ~ ruby -v
ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]
Verify that Ruby 2.7 has been installed:
➜ ~ brew install ruby#2.7
Warning: ruby#2.7 2.7.6_1 is already installed and up-to-date.
To reinstall 2.7.6_1, run:
brew reinstall ruby#2.7
What am I missing?
Type which ruby to find out where it's getting that executable from.
$ which ruby
/opt/homebrew/opt/ruby/bin/ruby
homebrew will put it in /opt/homebrew/opt/ruby/bin/ruby as shown there, but if that's not in your path then it will get the system ruby.
$ which ruby
/usr/bin/ruby
In that case you need to add the homebrew ruby bin directory to your PATH. I have this in my .bashrc:
export PATH="/opt/homebrew/opt/ruby/bin:/opt/homebrew/lib/ruby/gems/3.0.0/bin:$PATH"
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
$ bundle exec rake assets:precompile
Your Ruby version is 2.7.0, but your Gemfile specified 2.7.2
$ ~/.rvm/bin/rvm default do bundle exec rake assets:precompile
Your Ruby version is 2.7.0, but your Gemfile specified 2.7.2
$ ruby --version
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
$ ~/.rvm/bin/rvm default do ruby --version
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
$ which ruby
/home/sardsapp/.rvm/rubies/ruby-2.7.2/bin/ruby
I don't even know where to start with this. I even rebooted the machine, those commands are verbatim. I can't figure out what could possibly going wrong.
My Gemfile does specify 2.7.2, and that is my default version of ruby through rvm. I uninstalled all the other rvm versions of ruby. I don't have the ubuntu ruby package installed.
You can create a new gemset and switch the ruby version to 2.7.2
I have gone about the recommended way of installing a new version of Ruby on Mac OS X: Homebrew, and rvm. I ran rbenv to install Ruby 2.3.3, and selected it as the preferred version by using "rbenv global 2.3.3". The problem I am having is that there is currently a 2.0.0 version installed at /usr/bin/ruby, and for some crazy reason I am unable to remove it.
$ rbenv global
2.3.3
$ which ruby
/usr/bin/ruby
$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
$ ~/.rbenv/versions/2.3.3/bin/ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
sudo rm -rf /usr/bin/ruby
Password:
rm: /usr/bin/ruby: Operation not permitted
Argh!! Please help.
The problem is not your system Ruby, the problem is you probably didn't follow the rbenv installation instructions completely correctly.
The reason the system Ruby is located before your rbenv Ruby, is because your PATH has not been properly updated.
This explains why that is important:
https://github.com/rbenv/rbenv#understanding-path
To set up your PATH correctly you can read and complete steps 2-4 here:
https://github.com/rbenv/rbenv#basic-github-checkout
I am an inexperienced Ruby user and I want to start using a Jekyll theme. I am working on OSX El Capitan and there may be old Ruby tools lying around on this machine.
I have downloaded this theme and installed it to a local directory. Next I tried to run bundle and saw this error:
An error occurred while installing nokogiri (1.5.9), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.5.9'` succeeds before bundling.
Full error output here: http://pastebin.com/mv2r91xU
Next, I tried running gem install nokogiri -v '1.5.9', but I saw this error:
-bash: /usr/local/bin/gem: No such file or directory
I don't know how to install gem, and I suspect I'm not using the "right" Ruby or bundler. Where should these tools be? What do I need to check I've deleted to start cleanly from scratch? (e.g. I tried setting up rbenv, but I think it may have failed because I already had RVM installed)
These are the paths to ruby and bundler:
$ which ruby
/usr/bin/ruby
$ which bundle
/usr/local/bin/bundle
I'd suggest using rbenv to manage your Ruby versions, and ignoring the default system-wide version. You mention you tried, but I think it'd be worth giving it another go.
rbenv is best installed through Homebrew, install it with the following:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then install rbenv with Homebrew:
$ brew install rbenv ruby-build
You can then set and switch between Ruby versions (giving you clean environments) anytime without changing the default system version:
$ rbenv install 2.3.1
$ rbenv global 2.3.1
$ ruby -v
Once Ruby is sorted, you should be able to install and run the latest Jekyll through the Bundler:
$ gem install jekyll
$ jekyll new my-awesome-site
$ cd my-awesome-site
$ bundle install
$ bundle exec jekyll serve
Running Jekyll through Bundler rather than directly is the new suggested method.
I installed fxruby using
$sudo port install rb-fxruby
As suggested in the book.
It works, my hello world program worked correctly.
Now, though, other code that I have written is broken, whenever I try to use any code that relies on a gem, it does not work. When I do
$ruby -e "require 'rubygems'"
in my code, it gives
"LoadError: no such file to load — rubygems"
When I set my RUBYOPT="rubygems" in my .bash_profile
$ruby -e "puts 'hello world'"
ruby: no such file to load -- ubygems (LoadError)
(it says 'ubygems' without the 'r' on the front, not sure why)
http://newsgroups.derkeiler.com/Archive/Comp/comp.lang.ruby/2008-08/msg00351.html suggests I check my gem location against my ruby location, I get:
$cat `which gem` | head -n 1
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
$ls -l `which ruby`
-rwxr-xr-x 2 root admin 12680 Feb 7 03:40 /opt/local/bin/ruby
I assume this means that the gems are confused, but not sure how to remedy it. Any ideas? It sucks not having gems.
---UPDATE---
Forgot to list versions:
$which gem
/usr/bin/gem
$gem --version
1.3.5
$ruby --version
ruby 1.8.7 (2009-04-08 patchlevel 160) [i686-darwin9]
If you installed rb-fxruby via macport it will install the macport ruby as well.
$ port info rb-fxruby
...
Library Dependencies: ruby, fox, fxscintilla
...
But as you can see rb-rubygems (the macport version of rubygems) is not listed as a dependency, so you will have to install it manually.
$ sudo port install rb-rubygems
should do it for you.
It looks like you are trying to use the Apple-supplied gem that works with the Apple-supplied ruby. Did you install the MacPorts version?
sudo port install rb-rubygems
/opt/local/bin/gem