How to fix permissions error when installing Rails on Windows - ruby-on-rails

I have Ruby 2.2.6 and Rails 5.0 installed succesfully, however I don't seem to be able to install gems. Here's the error I get:
Errno::EACCES: Permission denied # rb_sysopen -
C:/RailsInstaller/Ruby2.3.0/lib/ruby/gems/2.3.0/gems/nokogiri-1.7.1-x86- mingw32/lib/nokogiri/2.3/nokogiri.so
An error occurred while installing nokogiri (1.7.1), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.7.1'` succeeds before bundling.
I searched for solutions but all the suggestions are for Unix commands.
I'm on Windows so I'm not sure how to enable permissions in order for this install to pass succesfully.
Any (ELI5 level) suggestions for me?

Have you tried executing:
gem install nokogiri -v '1.7.1'
In your command line?
If you are still getting an error, post the error message.

If you go to the Nokogiri website, you'll find special instructions for installing it on Windows.
A number of Ruby libraries are called native libraries, meaning they're written in C for Unix, and so require Unix build tools to make.

Related

Bundle install errors and cannot continue, even after installing missing gems

I am working on multiple Ruby on Rails applications and running...
MacOS 10.15.7,
Ruby 2.6.5,
Rails 5.2.3,
In a project app directory I am trying to run a bundle install and get the following error:
An error occurred while installing jaro_winkler (1.5.3), and Bundler cannot continue.
Make sure that `gem install jaro_winkler -v '1.5.3' --source
'https://.../api/gems/rubygems/'` succeeds before bundling.
I proceed to install the gem from the specified source and get confirmation of install
Building native extensions. This could take a while...
Successfully installed jaro_winkler-1.5.3
Parsing documentation for jaro_winkler-1.5.3
Done installing documentation for jaro_winkler after 0 seconds
1 gem installed
after running bundle install again, I will get the original error
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:
/private/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3/ext/jaro_winkler
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r
./siteconf20210406-62421-10txxc5.rb extconf.rb
creating Makefile
current directory:
/private/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3/ext/jaro_winkler
make "DESTDIR=" clean
current directory:
/private/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3/ext/jaro_winkler
make "DESTDIR="
make: *** No rule to make target
`/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19/ruby/config.h',
needed by `adj_matrix.o'. Stop.
make failed, exit code 2
Gem files will remain installed in
/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/gems/jaro_winkler-1.5.3
for inspection.
Results logged to
/var/folders/yr/dw4ljvv14cl9vp76jt_6zqrsv1qhkf/T/bundler20210406-62421-1bm7o1ijaro_winkler-1.5.3/extensions/universal-darwin-19/2.6.0/jaro_winkler-1.5.3/gem_make.out
An error occurred while installing jaro_winkler (1.5.3), and Bundler cannot continue.
Make sure that `gem install jaro_winkler -v '1.5.3' --source
'https://.../api/gems/rubygems/'` succeeds before bundling.
The error message above doesn't give me any clear indication of what is happening. Additionally there is no such directory in the location where the message says "results logged to."
This seems to be happening in multiple application directories - but with different affected gems in each directory. They are all similar in that the error reads "make sure gem succeeds before bundling", then the gem install will succeed, and then the following bundle install will fail with the same original message.
Earlier today I did a clean Ruby 2.6.5 install and updated the Xcode CLI via xcode-select --install
If I run gem which jaro_winkler I get
/Users/{username}/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/jaro_winkler-1.5.3/lib/jaro_winkler.rb
Does anyone have any information on what could be causing this? I cannot do any bundle install without this happening. Please let me know if any more information is desired.
Thank you!
You mentioned that you are using ruby 2.6.5, but the gem is attempting to be installed in 2.6.0. Check that your Gemfile has the correct Ruby version in it.
When you ran gem which, it looks you are using rbenv. Make sure that you are using the correct Ruby version in there, too. Those rubies get installed in a different directory than xcode's. Sometimes there's a .rbenv file in the dir that will set the version as well.
Just some ideas. Hopefully something sticks.
Ended up being an issue with gem install location - export PATH="/usr/local/bin:$PATH" was previously added to my .bash_profile and this was effecting where gems were installed.
Somewhere in the error message /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby is mentioned - this is the "system default" Mac version of Ruby and is not the Ruby version I was intending to use with .rbenv ( 2.6.5 ) and gem installs.
Removing the export mentioned above help resolve the issue.
edit- wording

An error occurred while installing nio4r (2.3.1) - fresh rails install

I'm installing rails on a new machine (high sierra to be exact) i've gone through the setup rails from go rails, however whenever i go to bundle install this is the following error:
Errno::EACCES: Permission denied # dir_s_mkdir - /Users/jake/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/nio4r-2.3.1
An error occurred while installing nio4r (2.3.1), and Bundler cannot continue.
Make sure that `gem install nio4r -v '2.3.1'` succeeds before bundling.
I've downloaded command line tools, i've downloaded xcode (the actual app) I also accidentally downloaded postgres (via command line) first, before mysql. I'm unsure whether this has anything to do with it
thanks in advance!
It appears i've installed nio4r-2.3.1 in sudo, and therefore didn't have the correct permissions to access it when not in sudo. i ran the following command to change the directory:
sudo chown -R jake ~/.rbenv
big thanks to The Tin Man for his details post on this: - How to fix a bundle install "nio4r error" on Rails 5.0.0

rails 4 An error occurred while installing json (1.8.2)

I was using the rails server this Am. Now i try to run my server on mac and I get:
Could not find json-1.8.2 in any of the sources
Run `bundle install` to install missing gems.
So i run bundle install and I get...
Fetching source index from https://rubygems.org/
Using rake (10.4.2)
Using CFPropertyList (2.3.1)
Using i18n (0.7.0)
Errno::EACCES: Permission denied - /Users/danielhatcher/.rvm/gems/ruby-2.0.0-p247/gems/json-1.8.2/tests/test_json.rb
An error occurred while installing json (1.8.2), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.2'` succeeds before bundling.
so i try running gem install json -v '1.8.2' and get this...
ERROR: Could not find a valid gem 'json' (= 1.8.2) in any repository
any help would be greatly appreciated. I can't find anything out on the net about this.
ruby 2.0.0p247
Are you just getting your workspace setup?
I had the same problems before when I was getting started.
I went to railsinstaller.org and development environment has been working well since then.
Hope this helps.
If I had to take a guess at this issue, I would say you opened a new shell since the AM and your new shell isn't configured to use the version of Ruby you installed with RVM.
I would take a look at this, https://rvm.io/rvm/basics
And basically make sure your using the version of Ruby that you installed with RVM, and that your shell is configured to use it.
And the latest version of the JSON gem appears to be 1.8.3 so you might want to try that version. https://rubygems.org/gems/json
I hope my comments help you out.

An error occurred while installing ruby-opencv (0.0.14)

I'm facing gem ruby-opencv installation issue
Gem files will remain installed in /home/k2/.rvm/gems/ruby-2.1.2#rails4/gems/ruby-opencv-0.0.14 for inspection.Results logged to /home/k2/.rvm/gems/ruby-2.1.2#rails4/extensions/x86_64-linux/2.1.0/ruby-opencv-0.0.14/gem_make.out
An error occurred while installing ruby-opencv (0.0.14), and Bundler cannot continue.
Make sure that `gem install ruby-opencv -v '0.0.14'` succeeds before bundling.
I tried below one also
gem install ruby-opencv -v '0.0.14'
ruby -v => 2.1.2
You need to download the opencv package from
https://github.com/Itseez/opencv/tree/master using,
git clone https://github.com/Itseez/opencv.git
or clicking on download button in that same page.
And install the above package using http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html
And then start to install the gem as below
gem install ruby-opencv -- --with-opencv-dir=/usr/local.
Now it will work.
Typically the Ruby opencv gem needs to compile native extensions, including the opencv tools, the sqlite database, the python language, openssl networking, and possibly access to your system's compiler such as gcc.
These extensions are generally easiest to diagnose by using sudo.
Try this if you can:
sudo gem install ruby-opencv -v '0.0.14'
Also, you may want to try changing from using rvm to using ruby-build.
Can you please edit your question, and add the results of the log file?
cat /home/k2/.rvm/gems/ruby-2.1.2#rails4/extensions/x86_64-linux/2.1.0/ruby-opencv-0.0.14/gem_make.out
Have you already installed OpenCV successfully on its own?
You can install OpenCV with these instructions: http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html
If you can install OpenCV, that may help verify you have most of the pieces you need for the Ruby gem.

Error while bundling Rails application (missing gems?)

Note: this is my first attempt with Ruby and Rails!
Once I've installed everything I tried to create a new app with
rails new rubyapp
the command created everything and then the bundler started. While running it stopped at
Errno::EACCES: Permission denied - /Library/Ruby/Gems/1.8/build_info/coffee-script-source-1.6.2.info
An error occurred while installing coffee-script-source (1.6.2), and Bundler cannot continue.
Make sure that `gem install coffee-script-source -v '1.6.2'` succeeds before bundling.
well.. no problem.. let's install this..
sudo gem install -p http://myproxy:8080 coffee-script-source -v '1.6.2'
Installing ri documentation for coffee-script-source-1.6.2
1 gem installed
Good. Try again.
bundle install
and stopped here:
Errno::EACCES: Permission denied - /Library/Ruby/Gems/1.8/build_info/execjs-1.4.0.info
An error occurred while installing execjs (1.4.0), and Bundler cannot continue.
Make sure that `gem install execjs -v '1.4.0'` succeeds before bundling.
!!!
Needless to say that I've installed this, tried again and the same error came up with different "gems".
My question is: is there a command to find if I've everything I need installed without doing these steps tons of times (also because they're pretty slow..)?
I've also tried bundling with sudo but maybe it's not working for the proxy.. : /
Thanks in advance
Just to help anyone still looking (I presume you fixed it in the end) running the command sudo chown myuser:myuser /Library/Ruby/Gems/1.8/build_info/ (where /Library/Ruby/Gems/1.8/build_info/ is the directory referenced in the error) fixed this.
I encourage you to install RVM (or rbenv) to install/uninstall ruby interpreters. Ruby interpreter bundled with Mac OS X is too old. Also gem installation procedure for system ruby interpreter requires superuser privileges.
If it is your first attempt to Rails world, please, start it with right tools, and actual ruby version (1.9.3).
Here you can find how to install RVM: https://rvm.io/rvm/install/
Good luck!

Resources