How do I run boxen in Mavericks with rbenv installed? - ruby

I recently upgraded to Mac OS 10.9 and now I get this message when I run boxen:
Bundler is not compatible with Ruby 2.0 or Rubygems 2.0. Please
upgrade to Bundler 1.3 or higher. Can't bootstrap, dependencies are
outdated
I imagined that I could just set boxen's .ruby-version file to something like 1.8.7, but based on the message above, it still seems to be using Ruby 2.0.
How can I run boxen in Mavericks?

I ran into the exact same issue. The answer is actually deceptively simple. Since Mavericks now includes Ruby 2.0.0p247 and Rubygems 2.0.3, and you apparently upgraded, your system ruby will not find your bundler or ansi gems. So what you need to do is install both with your system ruby, as root.
sudo /usr/bin/gem install bundler
sudo /usr/bin/gem install ansi
Then just restart or terminal. You can now run boxen as you would normally. Also, in order not to keep old files lying around, you may want to cleanup /Library/Ruby/Gems/1.8/ because it will include your old installation of both bundler and ansi on a ruby and gem installation you no longer have.

Seems the problem is with bundler. Just try to update it.
gem install bundler

system ruby (now 2.0) needed an updated version of bundler. Currently, only a pre-release version is compatible with Mac OS 10.9. If gem install bundler complains that you need a newer version of Bundler, as above, try gem install bundler --pre. Also, you may need elevated privileges to install gems for your system's ruby.
I am still confused about why Boxen wants to use system ruby's bundler gem when a different ruby installation is defined by Boxen's rbenv config, but the problem has a working solution now.

Related

Install ruby 2.7.3 on Mac M1 issue

When I try to install the ruby 2.7.3 version on mac m1 it installs, it shows in my machine also but when I try sudo bin/setup_dev this command its show me error like
Bundling rails dependencies Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on
this machine. Your Ruby version is 2.6.3, but your Gemfile specified ~> 2.7.3
bin/setup_dev:
Failed to run 'bundle install > log/setup_dev.log', check log/setup_dev.log for more information.
aim#aim-MacBook-Air openproject % rbenv global 2.7.3
aim#aim-MacBook-Air openproject % ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]
please any one can help to install ruby v 2.7.3 on mac.
Things that I try
Install ruby using rosetta 2
I am new on ruby please help on this.
thanks in advance.
Specifying a ruby version in a bundler gemfile doesn’t magically install that version of ruby. You need to start by learning to use a ruby version management system. I recommend Homebrew and rbenv.
(And not just in order to get a different ruby version. Always install your own ruby. Never use the built in system ruby for anything! If you have to say sudo you’re doing it wrong.)

Bundler version for Ruby 2.3.8?

I currently have 2 ruby versions, 2.5.5 and 2.3.8, I am managing them with rbenv, and for gems, I use bundler to manage my specific gem versions. I have an issue when I want to switch to a project that uses 2.3.8 or a version that has to do with Ruby version 2.3.
My question is how do I get bundler to run the command to bundle install interact with my 2.3 projects.
My current version of bundler is 2.0.2.
I have already tried installing a lower version of bundler of which the bundler website claims to interact with ruby version 2.3.
I thought that if I specified the command to run bundle _version_ install it would work, but it still gave me the response that it needed ruby version 2.5 for bundler to work.
Lots of help appreciated.
In some situations, isolation can help. I would like to recommend rvm (https://github.com/rvm/rvm) for managing ruby versions. This tool is very similar to rbenv but in comparison, it allows you to create gemsets which are kind of containers of gems for special purposes. For instance:
rvm install 2.5.5 --disable-binary
rvm use 2.5.5#name-of-gemset --create
gem install bundler
bundle install # inside your project folder with Gemfile
I think that you will not have problems with versions again.

How do I find which versions of ruby, gem and bundler are compatible?

I am using puppet to install ruby 1.9.3 as the system ruby on an Ubuntu Trusty Vagrant container. I also install Bundler. I am told that "gem" is installed as part of the installation of ruby.
How do I know which versions of gem go with this version of ruby?
How do I know which versions of bundler go with this version of ruby?
Here is a fragment of puppet code:
$other_reqs = [
...
'ruby1.9.3',
'ruby-bundler',
'rubygems-integration',
...
]
package{ $other_reqs: ensure => 'installed'} -> Package['percona-toolkit']
The package declaration will default to using apt-get to download packages. Clearly the line with 'ruby1.9.3' will get the 1.9.3 version of ruby. It also installed gem 1.8.23. Is this a compatible version of gem? How do I know?
The line with 'ruby-bundler' installed Bundler version 1.3.5. Is this a compatible version of Bundler? Or should I indicate a specific version in my requirements array? Where ought I look to find this information?
It might be helpful if you indicate the problem, or what you're trying to do. Nevertheless:
gem is a command that is built-in in ruby from 1.9+, so whatever comes installed with Ruby should be fine.
bunlder is a RubyGem, normally installed by doing gem install bundler. You can specify the version by doing gem install -v <version>. Either it gets installed correctly or you get an error. Can you install bundler doing that?
And lastly, unless you need it for a specific reason, 1.9 is very old :)

reinstall every gem for each ruby version?

I just installed Ruby 2.0.0 using rbenv and set it to the global ruby version for my system. Since 2.0 is compatible with 1.9.3, I tried to start up a Rails project with it, but got the following error. I did rbenv rehash after installing 2.0
The `rails' command exists in these Ruby versions:
1.9.3-p327
Does this mean that every gem I installed on my system with 1.9.3 has to be reinstalled if I wish to use it with 2.0?
As seen here:
You need to reinstall bundler for each version of Ruby you use. See Ruby versions where you have it installed:
rbenv whence bundle
See your current version:
rbenv version
Install bundler for that version, if missing:
gem install bundler
Yes. Rbenv (and RVM) have separate "gem home" directories for each installed version of Ruby. There may be ways to symlink certain directories to get them to share, but this will likely lead to problems, particularly with gems that include native C extensions, which may or may not compile and run cleanly in multiple versions.
If you have a Gemfile, easiest thing is to just bundle install again for Ruby 2.0, giving you duplicate copies of many gems and Ruby-2.0 compiled versions of any native gems.
Another solution to this is to copy (or reinstall) the gems from your previous version to the newly installed version. How to do that is answered in detail in this question, which has two scripts -- one to install from local cache, one to reinstall from the internet (mine).

How do I let bundle know I installed Ruby 1.9.2 on OS X Lion?

I installed Ruby 1.9.2 on OS X Lion using brew install ruby and updated gem to 1.8.11 using gem update --system.
However, on my Rails 3 project, bundle is still using the Ruby 1.8 path (/System/Library/Frameworks/Ruby.framework/Versions/1.8/Ruby) to install new gems and fails with packages that require Ruby 1.9 (linecache19 in my case).
How do I let bundle know that I installed 1.9.2?
(I tried using RVM to installed Ruby and failed for some reason. The installer simply hand. I think the network connection was too slow or something)
Did you set a default Ruby with RVM or create a .rvmrc in your Rails project? If not, do so and then install the Bundler gem for the correct Ruby version before doing a Bundle install.
Update: I kinda misread your question before. For your system you use Homebrew's Ruby, make sure /usr/local/bin comes in your PATH before /usr/bin (where the system Ruby lives).
I retried rvm and it now it works like a charm. Apparently, this is the way to go.

Resources