Bundler / Middleman: Errno::EPERM: Operation not permitted # apply2files (and Gem::FilePermissionError) - ruby

I'm trying to revive a Middleman app from 2014.
When I run bundle, I get the following:
Errno::EPERM: Operation not permitted # apply2files -
/Users/josua/Documents/Work/MuheimWebdesign/welthaupt/src/vendor/bundle/ruby/2.6.0/gems/json-1.8.1/.gitignore
An error occurred while installing json (1.8.1), and Bundler cannot
continue.
Make sure that `gem install json -v '1.8.1' --source 'http://rubygems.org/'`
succeeds before bundling.
In Gemfile:
font-awesome-middleman was resolved to 4.1.1, which depends on
middleman-core was resolved to 3.3.4, which depends on
padrino-helpers was resolved to 0.12.2, which depends on
padrino-support was resolved to 0.12.2, which depends on
activesupport was resolved to 4.1.4, which depends on
json
And when running gem install json -v '1.8.1' --source 'http://rubygems.org/', I get:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
What's interesting is that when I run ruby -v, I get a different version than 2.6.0:
ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.x86_64-darwin21]
Could this be the problem? And if so, how can I make sure that the correct ruby is being used?

Related

"bundle update" not working and installing in older version directory

In my jekyll folder, jekyll serve didn't work, showed missing dependencies.
On running bundle update in my jekyll site folder, it shows an error:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.5.0/gems/nokogiri-1.10.9/ext/nokogiri
/usr/bin/ruby2.5 -r ./siteconf20200629-9481-3yqsb7.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.5.0/gems/nokogiri-1.10.9 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-
1.10.9/gem_make.out
An error occurred while installing nokogiri (1.10.9), and Bundler cannot continue.
Make sure that `gem install nokogiri -v '1.10.9' --source 'https://rubygems.org/'` succeeds
before bundling.
In Gemfile:
rails was resolved to 6.0.3.2, which depends on
actioncable was resolved to 6.0.3.2, which depends on
actionpack was resolved to 6.0.3.2, which depends on
actionview was resolved to 6.0.3.2, which depends on
rails-dom-testing was resolved to 2.0.3, which depends on
nokogiri
The issue is, it's trying to install gem in directory of older ruby version 2.5.0, which I have uninstalled. Currently, my ruby version is(installed using rmv):
$ ruby -v
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
The ruby in use also shows same:
$ which ruby
/usr/share/rvm/rubies/ruby-2.7.0/bin/ruby
The bundle directory in use:
$ which bundle
/home/devesh/.rvm/gems/ruby-2.7.0/bin/bundle
So how can I fix this issue, so that on bundle update, it generates gems in new gem directory?
Maybe you could try gem install bundler first, then do bundle update

Update from ruby 2.2.0 to 2.5

I have a Rails (4.2.6) project that was written with ruby 2.2.0.
I am trying to upgrade to ruby 2.5. To do that, I changed in the Rails repo, the file .ruby-version to ruby-2.5.0.
In the terminal, the ruby version is correct:
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin17]
When I run
bundle update --bundler
I get following error:
6 warnings and 2 errors generated.
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /Users/albert/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/json-1.8.3 for inspection.
Results logged to /Users/albert/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/json-1.8.3/gem_make.out
An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.3'` succeeds before bundling.
In Gemfile:
rails was resolved to 4.2.6, which depends on
actionmailer was resolved to 4.2.6, which depends on
actionpack was resolved to 4.2.6, which depends on
actionview was resolved to 4.2.6, which depends on
rails-dom-testing was resolved to 1.0.7, which depends on
rails-deprecated_sanitizer was resolved to 1.0.3, which depends on
activesupport was resolved to 4.2.6, which depends on
json
I've tried to update manually the json gem:
gem install json -v '1.8.3'
Without success:
Getting SRV record failed: DNS result has no information for _rubygems._tcp.gems.rubyforge.org
HEAD http://gems.rubyforge.org/api/v1/dependencies
301 Moved Permanently
HEAD https://rubygems.org
200 OK
Getting SRV record failed: DNS result has no information for _rubygems._tcp.gems.github.com
HEAD http://gems.github.com/api/v1/dependencies
301 Moved Permanently
HEAD http://gems.github.io/api/v1/dependencies
404 Not Found
GET http://gems.github.com/prerelease_specs.4.8.gz
301 Moved Permanently
GET http://gems.github.io/prerelease_specs.4.8.gz
404 Not Found
GET http://gems.github.com/specs.4.8.gz
301 Moved Permanently
GET http://gems.github.io/specs.4.8.gz
404 Not Found
HEAD https://api.rubygems.org/api/v1/dependencies
200 OK
GET https://rubygems.org?gems=json
200 OK
ERROR: While executing gem ... (TypeError)
incompatible marshal file format (can't be read)
format version 4.8 required; 60.33 given
At this point, I don't know what to google, how to debug.
If I run
bundle install
I get following error
2: from ./bin/bundle:3:in `<main>'
1: from /Users/albert/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems.rb:263:in `bin_path'
/Users/albert/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': Could not find 'bundler' (1.14.3) required by your /Users/albert/localDocuments/CodingArea/Clients/hanspeter/book/Gemfile.lock. (Gem::GemNotFoundException)
To update to the lastest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:1.14.3`
Not sure what this means, what I have in the Gemfile.lock is:
bundler (>= 1.3.0, < 2.0)
And, im my Gemfile, I have as a source:
source 'https://rubygems.org'
```
As far as I understood, bundle is a gem manager that works on Mac, and bundler is a gem that manages gems?
It is because you have wrong gem resources.
Try these to correct it
gem sources -r http://gems.rubyforge.org/
gem sources -r http://gems.github.com
gem sources -a https://rubygems.org/
Then bundle again as you did

Rails bundle install doesn't work 'cause json version error

I just wanted to convert from ImageMagick v7 to ImageMagick v6.
while doing that, this error was happened.
bundle install doesn't work correctly.
It seems like json version is something wrong.
How do I fix this error?
Environment below
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin17]
Rails -v (couldn't find gem) (becuase bundle install can't work)
json list / json (default: 1.8.3)
multi_json (1.13.1, 1.11.2, 1.11.0)
Bundler version 1.16.4
Mac Mojave 10.14
when I do bundle install on terminal, then I got this error
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies.......
Using rake 12.3.2
Using concurrent-ruby 1.1.4
Using i18n 0.9.5
Fetching json 1.8.6
Installing json 1.8.6 with native extensions
Errno::EPERM: Operation not permitted # chmod_internal -
/Users/***/projects/***/vendor/bundle/ruby/2.3.0/gems/json-1.8.6/tests/test_json.rb
An error occurred while installing json (1.8.6), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.6' --source
'https://rubygems.org/'` succeeds before bundling.
In Gemfile:
rails was resolved to 4.2.6, which depends on
actionmailer was resolved to 4.2.6, which depends on
actionpack was resolved to 4.2.6, which depends on
actionview was resolved to 4.2.6, which depends on
rails-dom-testing was resolved to 1.0.9, which depends on
rails-deprecated_sanitizer was resolved to 1.0.3, which depends on
activesupport was resolved to 4.2.6, which depends on
json
I tried to do like this because error statement says Make sure that
gem install json -v '1.8.6' --source 'https://rubygems.org/' succeeds before bundling
but result shows like this
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted # chmod_internal - /Users/***/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/json-1.8.6/tests/test_json.rb
I can't understand this error statement
Errno::EPERM: Operation not permitted # chmod_internal -
Also, I goggled a lot, then I update commandlinetool follow this
https://howchoo.com/g/m2u0mmuwzda/macos-mojave-fix-invalid-active-developer-path
then, I did this command again,
sudo gem install json -v '1.8.6' --source 'https://rubygems.org/'
then, it's completely succeded like this.
Building native extensions. This could take a while...
Successfully installed json-1.8.6
Parsing documentation for json-1.8.6
Installing ri documentation for json-1.8.6
Done installing documentation for json after 1 seconds
1 gem installed
But, if I do bundle install, still doesn't work: they show same error.
My recommendation is if possible to start fresh. Maybe your rbenv was not installed correctly, try reinstalling it, I suggest using brew install rbenv https://github.com/rbenv/rbenv#homebrew-on-macos
Make sure to add the eval "$(rbenv init -)" to your ~/.bash_profile then open a new terminal.
Navigate to the project directory and install the Ruby version you need: rbenv install 2.3.1
You can make sure you are using that version by issuing rbenv use 2.3.1 and ruby --version.
Now install bundler for that Ruby version, I suggest 1.17.3 for now (the latest before 2.0.1) gem install bundler -v '1.17.3'.
You should be ready to bundle install.
The most common scenario I see for a message Installing ... with native extensions to result in errors is usually due to the lack of binaries, header files and C related code to build that native extension, in your case the issue is due to permissions, hence why I am suggesting some fresh installation.
I second #Danilo Cabello's recommendation to start fresh if you can. I just have a few other trouble-shooting ideas:
The fact that your bundle is installing gems in /vendor/bundle means that at some point, you must have specified the path with bundle install --path vendor/bundle as #mogbee alludes to. That path flag will load files associated with your gems into vendor/bundle instead of your system gem location. You might have done that if you're trying to keep the project's gems separate from any other project, but if not, you will need to update your bundler's gem path.
To do this, first, check for any issues by running bundle doctor. If no issues are found, check your bundle configuration with bundle env. Make sure that your RubyGems Gem Home and Gem Path are routed through .rbenv, so they should match and look like /Users/***/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0. If they don't match, run the rbenv-doctor command below which should make sure your rbenv installation exported the path properly.
If the output of bundle env tells you that you're actually running an older version of bundler (older than 1.16.4), I would definitely update, and would recommend version 1.17.3 as #Danilo Cabello did.
Second, I would run this rbenv-doctor curl command to check the status of your rbenv install: curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash (https://github.com/rbenv/rbenv-installer#rbenv-doctor).
Third, depending on the output of ls -l within your project folder, you may also want to recursively change owner/group for your ~/.rbenv folder to make sure everything is owned by you and not root (https://superuser.com/questions/260925/how-can-i-make-chown-work-recursively/260939#260939)

Install Bundle nokogiri Redmine Error Linux [duplicate]

This question already has answers here:
Error while installing json gem 'mkmf.rb can't find header files for ruby'
(19 answers)
Closed 4 years ago.
I need some help...
I have been following these instructions:
https://www.redmine.org/account/activate?token=2375a89a6b6f6a04b05bc941e93cb3ea82c15a89
I having an issue with this step:
Install dependencies using the Gem bundler¶
This step will look at the dependencies specified in the Gemfile:
% cd /var/www/redmine
% bundle install
When I run the command, I get this error:
[fit54#u ~]$ cd /var/www/redmine
[fit54#u redmine]$ bundle install
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x64-mingw32, x86-mswin32. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x64-mingw32 x86-mswin32`.
/usr/share/gems/gems/psych-2.0.0/lib/psych.rb:98: warning: already initialized constant Psych::VERSION
/usr/share/ruby/psych.rb:98: warning: previous definition of VERSION was here
/usr/share/gems/gems/psych-2.0.0/lib/psych.rb:101: warning: already initialized constant Psych::LIBYAML_VERSION
/usr/share/ruby/psych.rb:101: warning: previous definition of LIBYAML_VERSION was here
Fetching gem metadata from https://rubygems.org/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies....
Using rake 12.3.1
Using i18n 0.7.0
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 4.2.8
Using builder 3.2.3
Using erubis 2.7.0
Using mini_portile2 2.1.0
Fetching nokogiri 1.6.8.1
Installing nokogiri 1.6.8.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/fit54/.gem/ruby/gems/nokogiri-1.6.8.1/ext/nokogiri
/usr/bin/ruby -r ./siteconf20180406-9964-oibzlr.rb extconf.rb
--use-system-libraries
mkmf.rb can't find header files for ruby at /usr/share/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /home/fit54/.gem/ruby/gems/nokogiri-1.6.8.1
for inspection.
Results logged to
/home/fit54/.gem/ruby/extensions/x86_64-linux/nokogiri-1.6.8.1/gem_make.out
An error occurred while installing nokogiri (1.6.8.1), and Bundler
cannot continue.
Make sure that `gem install nokogiri -v '1.6.8.1'` succeeds before bundling.
In Gemfile:
rails was resolved to 4.2.8, which depends on
actionmailer was resolved to 4.2.8, which depends on
actionpack was resolved to 4.2.8, which depends on
actionview was resolved to 4.2.8, which depends on
rails-dom-testing was resolved to 1.0.9, which depends on
nokogiri
Please let me know what other information I need to provide or what help can be given to me to help resolve this issue.
sudo apt-get install ruby`ruby -e 'puts RUBY_VERSION[/\d+\.\d+/]'`-dev
There is no ruby dev environment which is why native extensions cannot be built. Give the above command a try- it should fix the issue.

bundle install using wrong ruby with rvm when building native extension?

I'm using bundle install to install rest-client. It's failing with the following:
$ bundle
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Installing unf_ext 0.0.7.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/gems/unf_ext-0.0.7.4/ext/unf_ext
/usr/bin/ruby2.3 -r ./siteconf20180115-9722-1iow75n.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/gems/unf_ext-0.0.7.4 for inspection.
Results logged to /home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/extensions/x86_64-linux/2.3.0/unf_ext-0.0.7.4/gem_make.out
Installing mime-types-data 3.2016.0521
Installing netrc 0.11.0
Using bundler 1.11.2
An error occurred while installing unf_ext (0.0.7.4), and Bundler cannot continue.
Make sure that `gem install unf_ext -v '0.0.7.4'` succeeds before bundling.
I'm using rvm, which appears to be working correctly, if I'm reading the output from rvm info right.
which ruby reports /home/roger/.rvm/rubies/ruby-2.3.4/bin/ruby, which looks right.
I found Install ruby headers with rvm, but I have Ruby headers in (apparently) the correct place:
$ ruby -rmkmf -e 'print RbConfig::CONFIG["rubyhdrdir"]'
/home/roger/.rvm/rubies/ruby-2.3.4/include/ruby-2.3.0
$ ls /home/roger/.rvm/rubies/ruby-2.3.4/include/ruby-2.3.0
ruby/ ruby.h x86_64-linux/
In the output from bundle, I see /usr/bin/ruby2.3, which looks suspicious.
It's looking in the wrong place for Ruby header files. How do I get it to use the RVM-installed ones?
I was using the wrong bundle.
$ which bundle
/usr/bin/bundle
Either the one included in Ubuntu 16.04 is old, or using the system-installed bundler doesn't work with rvm-installed Ruby.
$ gem install bundler
Fetching: bundler-1.16.1.gem (100%)
...
1 gem installed
$ which bundle
/home/roger/.rvm/gems/ruby-2.3.4#junk-drawer/bin/bundle
That looks better.
$ bundle
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Using bundler 1.16.1
...
Bundle complete! 1 Gemfile dependency, 9 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Lesson learned: when using rvm, remember to gem install bundler as well.

Resources