LoadError enc/trans/single_byte.so - ruby-on-rails

I receive the following error when attempting to do string.encode("UTF-8") with a non-ascii character.
LoadError: dlopen(enc/trans/single_byte.so, 9): image not found - enc/trans/single_byte.so
Unlike the answer here, it appears that this file does not exist in my ruby install, or anywhere else on the system for that matter. I'm running ruby 2.1.7 and bundler 1.10.6, running on Mac OSX 10.11.5. I tried reinstalling ruby (using RVM) with no success.
Should this file exist, and if so what do I need to install?

I would suggest trying to install it using chruby + ruby-install. You can use ruby-install to install any Ruby version you would like, and chruby is a small utility for switching between Ruby versions.
I've seen RVM have issues occasionally, and re-installing Ruby with ruby-install seemingly fixes the issues.
I have a guide for that here: http://ryanbigg.com/2015/06/mac-os-x-ruby-ruby-install-chruby-and-you/
Here's the steps in condensed form:
# Installs XCode development tools package
xcode-select --install
# Installs Homebrew (skip if you've done this already)
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install chruby ruby-install
ruby-install -V # this should show ruby-install: 0.6.0
ruby-install ruby 2.1.7
Add this line to ~/.bashrc:
source /usr/local/opt/chruby/share/chruby/auto.sh
Reload ~/.bashrc:
. ~/.bashrc
Running chruby should now show you ruby-2.1.7 and running ruby -v should show you 2.1.7 too.

Related

ruby -v says no such file or directory in mac os

I had the original ruby v2.6.8 I believe on my mac os. I wanted to upgrade to ruby 3.1.2 to get access to rails.
I installed ruby via homebrew, however I decided it woud be easier to manage using rbenv. I went to uninstall ruby via homebrew, and then instaled ruby 3.1.2 with rbenv.
Now when I use the
ruby -v
-bash: /usr/local/opt/ruby/bin/ruby: No such file or directory
using the command which ruby brings me this:
/Users/user/.rbenv/shims/ruby
So the ruby is there, and rbenv claims it installed ruby 3.1.2, but did homebrew install all of ruby including the version osx came with? Im pretty sure thats a yikes moment if it did. I also can't use any ruby commands under these circumstances so I don't really know what to do from here?
How do I get my $PATH to recognize the rbenv path to ruby as the global path? I'm on MacOs 11.3.1 BigSur if thats relevant.
Follow the next steps to set up rbenv, and ruby 3.1.2.
Step 1
brew install rbenv
Step 2 Add the following lines to your .zshrc file
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init - zsh)"
Step 3
brew update && brew upgrade ruby-build
Step 4
rbenv install 3.1.2
rbenv global 3.1.2

Fix Your Ruby version is 2.6.8, but your gemfile specified 2.5.5

On my local machine I'm using rbenv
When I run bundle install I get:
The git source `git://github.com/sinatra/sinatra.git` uses the `git` protocol, which transmits data without encryption. Disable this warning with `bundle config git.allow_insecure true`, or switch to the `https` protocol to keep your data secure.
Warning: the running version of Bundler (1.17.2) is older than the version that created the lockfile (1.17.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Following files may not be writable, so sudo is needed:
/Library/Ruby/Gems/2.6.0
/Library/Ruby/Gems/2.6.0/build_info
/Library/Ruby/Gems/2.6.0/cache
/Library/Ruby/Gems/2.6.0/doc
/Library/Ruby/Gems/2.6.0/extensions
/Library/Ruby/Gems/2.6.0/gems
/Library/Ruby/Gems/2.6.0/specifications
Your Ruby version is 2.6.8, but your Gemfile specified 2.5.5
The problem is, when I run rbenv versions, I get the right version (2.5.5):
system
* 2.5.5 (set by /Users/Mahmoud/dev-reps/non-docker/normal/.ruby-version)
And when I run which ruby, it correctly points to rbenv:
/Users/Mahmoud/.rbenv/shims/ruby
Even ruby -v gives the correct version:
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin21]
So persumably, 2.5.5 is the ONLY version I have.
In addition to this I tried all the usual hacks related to bundler:
bundle uninstall, gem uninstall bundler -v 1.17.2
but nothing seems to work.
Another "interesting" fact that I think gives a hint: which bundle gives:
/usr/local/bin/bundle
My question is where is this 2.6.8 coming from? And how can I fix this and start the server?
Finally got it working.
So the key to the problem as well to the solution was the fact that which bundle gave:
/usr/local/bin/bundle
while which ruby gave:
/Users/Mahmoud/.rbenv/shims/ruby
indicating that bundle isn't using ruby from rbenv.
I already had the path set in ~/.bash_profile:
export PATH="$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"
but apparently this was not enough as I was using zsh. Had to add those same 2 lines to ~/.zshrc as well and restarted terminal. Now bundle install is working as expected.
After updating ~/.zshrc which bundle gives:
/Users/Mahmoud/.rbenv/shims/bundle
indicating that the problem was just that bundle was using the wrong ruby.
So if you have this problem, just make sure ~/.bash_profile and ~/.zshrc have the correct path by adding the 2 lines indicated above. Restart terminal and check if its working now.
for Mac
Switch Ruby version with asdf
asdf shell Ruby 3.1.0 (any version)
Switch Ruby version with chruby
chRuby 3.1.0 (any version)
Switch Ruby version with rbenv
rbenv shell 3.0.0 (any version)
Switch Ruby version with rvm
rvm use 3.0.0 (any version)
for other information https://mac.install.guide/faq/downgrade-ruby/index.html
I was getting the issue
"Fix Your Ruby version is 2.6.8, but your gemfile specified 2.7.6"
So i have the followed the below steps
brew install ruby#2.7
\curl -sSL https://get.rvm.io | bash -s stable
rvm install "ruby-2.7.6"
Open your directory where you are planning to create React-Native project and run
/bin/bash --login
rvm use 2.7.6
Then you will see magic ....Your project will create with no error
Or You can do another thing
npx react-native init ProjectName --skip-install
cd ProjectName
yarn install
cd ios
pod install
cd ..
npx react-native run-ios
Try this (it just now helped me):
Delete this file:
/usr/local/bin/bundle
and try react-native init
Taken from: https://github.com/facebook/react-native/issues/35873#issuecomment-1397186611

Failed gem install: gem require ruby-2.6.1 but the currently ruby-2.6.1

Show messages errors:
Required ruby-2.6.1 is not installed.
To install do: 'rvm install "ruby-2.6.1"'
ruby -v
ruby 2.6.1p33 (2019-01-30 revision 66950) [x64-mingw32]
rails -v
Rails 5.2.2
First of all, I doubt that RVM may not be updated to support this version of Ruby. As I know the following version is supported, you can version by following command and response should match.
rvm --version
1.29.7
If you have updated version then I will do the following to check if RVM has also the same version of ruby installed.
I will check the content of my project root folder's following file
cat .ruby-version
If it has mention same, as rvm is also complaining that I will run the following command on rvm to check if this ruby is really installed in RVM
rvm list
It will show a list of rubies installed and it should include 2.6.1 in the end. If you can't see this list then you probably need to install using the following command
rvm install "ruby-2.6.1"
If it is showing than can you try the following command and see what result comes
rvm use 2.6.1
If all good, then try the following command to see which ruby is being used
which ruby
response must include .rvm/rubies/ mean you are using .rvm ruby otherwise, you may using the system built in ruby.
Just wrote may help you to diagnos issue.
Are you using rbenv? If so, I'd recommend running rvm implode as described here.
if you are using rbenv
see if you have it available in your list :
rbenv install --list | grep 2.6.1
if not, fetch it
cd ~/.rbenv/plugins/ruby-build && git pull && cd -
now if you try again
rbenv install -l | grep 2.6.1
so just run the installation command:
rbenv install 2.6.1
Downloading ruby-2.6.1.tar.bz2... 08:36:17
-> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.1.tar.bz2
Installing ruby-2.6.1...
Installed ruby-2.6.1 to ~/.rbenv/versions/2.6.1
now you can use it for global or local projects. if local :
rbenv local 2.6.1

Trying to set up Ruby Rails on Mac

Am trying to set up rails on mac using rbenv and Homebrew.
Currently getting the following message when attempting to 'gem install rails':
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
username-mbp:projects username$ gem install rails
Any ideas??
If you are using rbenv, you should not use sudo to install gems. rbenv very helpfully installs your gems under your home directory in a way that allows you to use different gems for each installed Ruby version. When you change versions of Ruby you will really appreciate this.
To see the current version of Ruby, use rbenv local. For me this prints:
2.2.2
To see all the Ruby versions on your system of which rbenv is aware:
rbenv versions
rbenv stores the version specifier in a file called .ruby-version. This allows you to use different versions of Ruby for different projects, each version having its own set of gems.
When you try to install rails and get the Gem::FilePermissionError, it means that rbenv is not active, or you are deliberately installing into the "system" Ruby. There is nothing wrong with this per se, but you are not taking advantage of rbenv.
I recommend installing Rails again, using rbenv local to ensure that you are adding the gems to the correct path. You'll know this is working when
gem env gemdir
produces something like:
/Users/username/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0
See https://github.com/sstephenson/rbenv#installation for more info.
This probably means that you used sudoat some point, which means that you run a command that allows you (as a permitted user to execute a command as the superuser or another user) See here: http://linux.about.com/od/commands/l/blcmdl8_sudo.htm.
Can you please paste the commands you used for installing rbenv, ruby, gem, brew, etc.? Also please paste the output of brew doctorto see if environment is correctly configured for Homebrew. Also, please paste the OSX version and rbenv versionsif rbenv is installed.
The steps for installing ruby on rails on OSX are:
Install Homebrew by:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`` (as seen here: http://brew.sh/). Run brew doctor and brew updateto see if everything is fine.
Install ruby: OS X comes with Ruby installed (Mavericks/Yosemite even gets version 2.0.0, previously it was only 1.8.7).
Install rbenv: it can be done either by GitHub Checkout or Brew. You probably should use brew. Run brew install rbenv ruby-build(this will also install ruby-build -https://github.com/sstephenson/ruby-build#readme-). You can also use this command brew install rbenv ruby-build rbenv-gem-rehash. Then echo 'eval "$(rbenv init -)"' >> ~/.bash_profile (to enable shims and autocompletion). You should problably run this too: echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile. Close terminal and open it again. Install the preferred version of ruby (if you want): rbenv install 2.0.0-p353.
Install Bundler: gem install bundler.
Install SQLite: gem install sqlite3
Install Rails: gem install rails.
So, the error you are having is due to permissions (you can understand about them here: http://www.tutorialspoint.com/unix/unix-file-permission.htm). Many people suggest fixing the issue with sudo or chown (http://www.cyberciti.biz/faq/how-to-use-chmod-and-chown-command/). I don't recommend that as it messes with system configuration. It will be better that you run:
rbenv install 2.1.2
rbenv global 2.1.2
gem update --system
When I run with this error like a year ago, what I did was uninstall everything and start again... but, probably that'll take too long.
These links might help you:
ruby for mac, ruby rbenv, rbenv githube, rubies and gems, question on stack
Use sudo:
sudo gem install rails
This guide helped me a lot: Setup Ruby On Rails on
Mac OS X 10.10 Yosemite

Installing Rails on Mac OS Yosemite v10.10.2 (FNG)

I'm trying to install Rails onto my Mac and keep running into a this issue. I have no coding/programming experience and am trying to get set up so I can start learning.
I have gone through everything on install rails.com and am not sure what to do.
Your help is appreciated.
make install failed, exit code 2
Gem files will remain installed in /Users/feferrada/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /Users/feferrada/.rvm/rubies/ruby-2.2.0/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-14/2.2.0-static/nokogiri-1.6.6.2/gem_make.out
Follow the steps below to install ruby on rails on mac osx yosemite.
If that does not work please post the exact errors.
For further details about the installation have a look at https://gorails.com/setup/osx/10.10-yosemite
Installing Homebrew
You might be asked to install the XCode CommandLine Tools - say yes.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installing Ruby
you can browse the available versions using
rbenv install --list
installation using homebrew
brew install rbenv ruby-build
# Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile
# Install Ruby
rbenv install 2.2.1
rbenv global 2.2.1
now ruby is installed and you should be able to run
ruby -v
# ruby 2.2.1...
Installing Rails
you can browse the available versions of rails using
gem list ^rails$ --remove --all
installation
gem install rails -v 4.2.1
to use the rails command run
rbenv rehash
now rails is installed and you should be able run
rails -v
# Rails 4.2.1

Resources