`rename': Permission denied # sys_fail2 - ruby

PS C:\Users\Roman> ruby dk.rb install
[INFO] Updating convenience notice gem override for 'C:/Program Files (x86)/Heroku/ruby-1.9.3'
dk.rb:86:in `rename': Permission denied # sys_fail2 - (C:/Program Files (x86)/Heroku/ruby-1.9.3/lib/ruby/site_ruby/1.9.1
/rubygems/defaults/operating_system.rb, C:/Program Files (x86)/Heroku/ruby-1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/defau
lts/operating_system.rb.20141106064922) (Errno::EACCES)
from dk.rb:86:in `update_gem_override'
from dk.rb:260:in `block (2 levels) in install'
from dk.rb:246:in `each'
from dk.rb:246:in `block in install'
from dk.rb:219:in `each'
from dk.rb:219:in `install'
from dk.rb:313:in `run'
from dk.rb:332:in `<main>'
Trying to install the devkit. "ruby dk.rb init" went without a hitch. Then this happens. Any ideas?

Currently, this is a problem with Ruby being installed to C:\Program Files\ without administator priviledges. For some reason, a copy of Ruby exists in my version of Heroku. This is autodetected by the devkit, and when it tries to install it there, it fails.
When ruby dk.rb init executes, a YAML file is created, called config.yaml, and all the paths of detected version of Ruby are added to it. By opening config.yaml and editing out the Heroku path, the problem was solved.
I hope this is helpful for other users.
Found the help I needed here.

Run cmd as an administrator and then run ruby dk.rb install command where have you extracted Devkit.
To run cmd as an administator:
type cmd in start menu
right click cmd.exe
click Run as administrator.
After successful completion of command, you will see something like below:
[INFO] Updating convenience notice gem override for 'C:/Program Files (x86)/Hero
ku/ruby-2.1.7'
[INFO] Installing 'C:/Program Files (x86)/Heroku/ruby-2.1.7/lib/ruby/site_ruby/d
evkit.rb'

Related

Ruby on Windows: `ansi.rb` get_screen_size error: in `winsize': Bad file descriptor - <STDIN> (Errno::EBADF)

I'm trying to use fastlane on Windows, which is installed from Bundler -- which is installed by Ruby Gem. But while running, some internal error of Ruby seems blocked the execution.
First, I went to Ruby Installer and installed Ruby+Devkit 3.0.2-1 (x64); then, I installed the Bundler and Fastlane using gem command. Error below happened when I was trying to execute them -- which I believed was not related to Bundler nor Fastlane:
C:/Ruby30-x64/lib/ruby/3.0.0/reline/ansi.rb:157:in `winsize': Bad file descriptor - <STDIN> (Errno::EBADF)
from C:/Ruby30-x64/lib/ruby/3.0.0/reline/ansi.rb:157:in `get_screen_size'
from C:/Ruby30-x64/lib/ruby/3.0.0/reline.rb:168:in `get_screen_size'
from C:/Ruby30-x64/lib/ruby/3.0.0/forwardable.rb:238:in `get_screen_size'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tty-screen-0.8.1/lib/tty/screen.rb:236:in `size_from_readline'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tty-screen-0.8.1/lib/tty/screen.rb:66:in `size'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tty-screen-0.8.1/lib/tty/screen.rb:76:in `width'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane_core/lib/fastlane_core/print_table.rb:95:in `transform_output'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/plugins/plugin_manager.rb:335:in `print_plugin_information'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/plugins/plugin_manager.rb:316:in `load_plugins'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/commands_generator.rb:39:in `start'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/fastlane/lib/fastlane/cli_tools_distributor.rb:122:in `take_off'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/fastlane-2.197.0/bin/fastlane:23:in `<top (required)>'
from C:/Ruby30-x64/bin/fastlane:23:in `load'
from C:/Ruby30-x64/bin/fastlane:23:in `<main>'
I'm using Windows 10 home version 20H2.
Rebooting the computer doesn't solve the problem.
I tried googling the question, but it seems that problem hasn't be reported (or be answered). I don't know where I can report the bug either.
What can I do? Any help would be appreciated!
I had this same error when I tried running bundle exec fastlane in git bash.
I got it working by running it in powershell instead.

Permission denied # dir_s_mkdir (Errno::EACCES) after installing RVM RUBY AND SHOPIFY-CLI

I have been stranded with this 5 hours today, and no online answers seem to exist for my problem....
I just installed .rvm and ruby + gem in order to start as a Shopify Developer. As a installed shopify-cli, and consequently log shopify version, I get this:
roger.rangel#Rogers-MacBook-Pro Current % shopify version
/Users/roger.rangel/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/fileutils.rb:253:in mkdir': Permission denied # dir_s_mkdir - /Users/roger.rangel/.config/shopify (Errno::EACCES) from /Users/roger.rangel/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/fileutils.rb:253:in fu_mkdir'
from /Users/roger.rangel/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/fileutils.rb:231:in block (2 levels) in mkdir_p' from /Users/roger.rangel/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/fileutils.rb:229:in reverse_each'
from /Users/roger.rangel/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/fileutils.rb:229:in block in mkdir_p' from /Users/roger.rangel/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/fileutils.rb:211:in each'
from /Users/roger.rangel/.rvm/rubies/ruby-3.0.2/lib/ruby/3.0.0/fileutils.rb:211:in mkdir_p' from /Users/roger.rangel/.rvm/gems/ruby-3.0.2/gems/shopify-cli-2.3.0/vendor/deps/cli-kit/lib/cli/kit/config.rb:128:in write_config'
from /Users/roger.rangel/.rvm/gems/ruby-3.0.2/gems/shopify-cli-2.3.0/vendor/deps/cli-kit/lib/cli/kit/config.rb:55:in set' from /Users/roger.rangel/.rvm/gems/ruby-3.0.2/gems/shopify-cli-2.3.0/lib/shopify-cli/context.rb:607:in update_time_of_last_check'
from /Users/roger.rangel/.rvm/gems/ruby-3.0.2/gems/shopify-cli-2.3.0/lib/shopify-cli/context.rb:560:in new_version' from /Users/roger.rangel/.rvm/gems/ruby-3.0.2/gems/shopify-cli-2.3.0/lib/shopify-cli/core/entry_point.rb:13:in call'
from /Users/roger.rangel/.rvm/gems/ruby-3.0.2/gems/shopify-cli-2.3.0/bin/shopify:33:in block in <main>' from /Users/roger.rangel/.rvm/gems/ruby-3.0.2/gems/shopify-cli-2.3.0/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb:75:in handle_abort'
from /Users/roger.rangel/.rvm/gems/ruby-3.0.2/gems/shopify-cli-2.3.0/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb:21:in call' from /Users/roger.rangel/.rvm/gems/ruby-3.0.2/gems/shopify-cli-2.3.0/bin/shopify:32:in '
How can I just get rid of this problem???? I am new to web development :(
This sometimes happens when you have run some install command as root. That is, if you have for instance installed rvm using sudo for some command - which has put the ownership of a directory to the root user of your computer (remember that MacOS is essentially UNIX with a nice UI).
To solve it, in your terminal you have to run
sudo chown -R roger.rangel: /Users/roger.rangel/.config
Another possibility is that you just don't have that directory, in that case, again in your terminal
mkdir /Users/roger.rangel/.config

How to use system Ruby instead of rbenv on a per-project basis?

I'm using my work laptop to contribute to a non-work open-source project. At work we use rbenv to manage Ruby versions, but the open-source project appears to expect gem dependencies to be located in the system Ruby install folder. So when I try to run certain of the project's commands, I'm running into missing gem errors.
The project is Homebrew, and the command I'm running is brew style. When I run the command in my local, I get the following:
Ignoring rainbow-2.2.2 because its extensions are not built. Try: gem pristine rainbow --version 2.2.2
/usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- rainbow (LoadError)
from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/richie.thomas/.gem/ruby/2.3.0/gems/rubocop-0.50.0/lib/rubocop.rb:4:in `<top (required)>'
from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/2.3.3/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/richie.thomas/.gem/ruby/2.3.0/gems/rubocop-0.50.0/bin/rubocop:6:in `<top (required)>'
from /Users/richie.thomas/.gem/ruby/2.3.0/bin/rubocop:22:in `load'
from /Users/richie.thomas/.gem/ruby/2.3.0/bin/rubocop:22:in `<main>'
Running gem environment returns the following:
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.10
- RUBY VERSION: 2.3.3 (2016-11-21 patchlevel 222) [x86_64-darwin15]
- INSTALLATION DIRECTORY: /Users/richie.thomas/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/richie.thomas/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /Users/richie.thomas/.rbenv/versions/2.3.3/bin/ruby
- EXECUTABLE DIRECTORY: /Users/richie.thomas/.rbenv/versions/2.3.3/bin
- SPEC CACHE DIRECTORY: /Users/richie.thomas/.gem/specs
....
I've been advised by other contributors that the easiest path forward would be to disable or uninstall rbenv in order to run the command. I'd really like to avoid uninstalling and reinstalling rbenv every time I want to run this command, but there is nothing in the rbenv documentation that mentions this.
Is there any one-time command I can run, or any configuration setting I can change, so that I can do what I need to do?
I re-ran gem environment and noticed that the following environment variables were defined:
INSTALLATION DIRECTORY: /Users/richie.thomas/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0
USER INSTALLATION DIRECTORY: /Users/richie.thomas/.gem/ruby/2.3.0
The value of INSTALLATION DIRECTORY is what I expected to be used to run the command, and I noticed the value of USER INSTALLATION DIRECTORY is what showed up in the error stacktrace.
Since I was unable to figure out how my machine was determining which variable to use, I simply renamed ~/.gem/ to ~/.gem2/ and re-ran the brew style command I originally wanted. This was successful!

How can I fix this "cannot load such file" error?

I'm applying to AppAcademy and need to do some exercises so I downloaded the ZIP as required from https://github.com/appacademy/test-first-ruby
I saved the file to my desktop and ran bundle install while inside the folder like the. Then through the terminal I go to the spec folder where the exercises are located and run the following command:
bundle exec rspec spec/00_hello_spec.rb
I get the following error:
Macintosh-2:spec Michael$ bundle exec rspec spec/00_hello_spec.rb
/Users/Michael/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core 2.99.1/lib/rspec/core/configuration.rb:1065:in `load': cannot load such file -- /Users/Michael/Desktop/RubyCodes/test-first-ruby-master/spec/spec/00_hello_spec.rb (LoadError)
from /Users/Michael/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in `block in load_spec_files'
from /Users/Michael/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in `each'
from /Users/Michael/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1065:in `load_spec_files'
from /Users/Michael/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/command_line.rb:18:in `run'
from /Users/Michael/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/runner.rb:103:in `run'
from /Users/Michael/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/rspec-core-2.99.1/lib/rspec/core/runner.rb:17:in `block in autorun'
I have ruby 2.1.3, bundler 1.7.9, and rspec 2.99.1.
What is causing this error and how can I fix it?
It looks like you may be running the command from the wrong directory. Consider your error message:
`load': cannot load such file -- /Users/Michael/Desktop/RubyCodes/test-first-ruby-master/spec/spec/00_hello_spec.rb (LoadError)
and notice that the spec directory appears twice in the error message's file path. This implies the existence of a spec directory within a spec directory. It's more likely that there is just one spec directory. Within your same terminal context, run the following command to bring you up one directory level:
cd ..
then try your command again:
bundle exec rspec spec/00_hello_spec.rb
You can think of cd as standing for "change directory" while .. represents one directory level above the current level (the current level is represented with a .).
Alternatively, you can run the following command from within the spec directory:
bundle exec rspec 00_hello_spec.rb

Invalid spec cache file

I have ruby 2.0.0p247 [x64-mingw32] with Gem 2.2.2 installed on Windows 8. I have a persistent problem gem that is making it virtually unusable. Whenever I try to install a new gem, I invariably get:
ERROR: While executing gem ... Invalid spec cache file in C:/Users/...
In the past, I've been able to run gem update or gem update --system and that would clear up the problem for one, single gem install. Subsequent install would fail with the same error. Now even gem update fails with that error message.
I've tried deleting the users/.../.gem directory. When I do that, gem update recreates that directory and promptly fails with the same error message.
I re-installed ruby 1.9.8 with gems several times to try to cure the problem, then upgraded to ruby 2.0.0. Throughout all re-installs and upgrades, the problem persisted.
I'm at my wits end here. Can anyone help me resolve this issue?
Here's the backtrace on the edit"
L:\xampp\htdocs\frameworks\yii2\framework>gem update --backtrace
Updating installed gems
ERROR: While executing gem ... (Gem::Exception)
Invalid spec cache file in C:/Users/Larry/.gem/specs/rubygems.org%443/specs.4.8
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source.rb:187:in `rescue in load_specs'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source.rb:179:in `load_specs'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:266:in `tuples_for'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:228:in `block in available_specs'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source_list.rb:97:in `each'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/source_list.rb:97:in `each_source'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:222:in `available_specs'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/spec_fetcher.rb:102:in `search_for_dependency'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:113:in `fetch_remote_gems'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:135:in `highest_remote_version'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:264:in `block in which_to_update'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:260:in `each'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:260:in `which_to_update'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/commands/update_command.rb:96:in `execute'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/command.rb:305:in `invoke_with_build_args'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/command_manager.rb:167:in `process_args'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/command_manager.rb:137:in `run'
C:/Ruby200-x64/lib/ruby/site_ruby/2.0.0/rubygems/gem_runner.rb:54:in `run'
C:/Ruby200-x64/bin/gem:21:in `<main>'
I had the same problem, but was able to fix it this way:
Delete the folder in users/%user%/.gem/ and rerun the command gem sources --update
Hope this helps.

Resources