Debugging ruby in RubyMine - ruby-on-rails

I am new to Ruby and RubyMine but I have tried essentially everything I have found online but can't get the debugger to work in RubyMine, keep getting the following error:
Error running 'simple_array_sum': Failed to Install Gems. Following gems were not installed: /Applications/RubyMine.app/Contents/rb/gems/ruby-debug-ide-0.6.1.beta9.gem: Error installing ruby-debug-ide-0.6.1.beta9.gem: ERROR: Failed to build gem native extension. current directory: /Users/ruskindantra/.gem/ruby/2.3.0/gems/ruby-debug-ide-0.6.1.beta9/ext /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby mkrf_conf.rb Installing base gem Permission denied # dir_s_mkdir - /Library/Ruby /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:253:in `mkdir' /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:253:in `fu_mkdir' /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:227:in `block (2 levels) in mkdir_p' /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:225:in `reverse_each' /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:225:in `block in mkdir_p' /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:211:in `each' /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/fileutils.rb:211:in `mkdir_p' /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/installer.rb:691:in `verify_gem_home' /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/installer.rb:811:in `pre_install_checks' /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/installer.rb:278:in `install' /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/resolver/specification.rb:97:in `install' /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/request_set.rb:166:in `block in install' /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/request_set.rb:156:in `each' /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/request_set.rb:156:in `install' /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/dependency_installer.rb:405:in `install' mkrf_conf.rb:35:in `rescue in ' mkrf_conf.rb:28:in ` ' rake failed, exit code 1 Gem files will remain installed in /Users/ruskindantra/.gem/ruby/2.3.0/gems/ruby-debug-ide-0.6.1.beta9 for inspection. Results logged to /Users/ruskindantra/.gem/ruby/2.3.0/extensions/universal-darwin-17/2.3.0/ruby-debug-ide-0.6.1.beta9/gem_make.out
Can anyone please help?

The problem is that RubyMine is pointing at the system version of Ruby. I would recommend starting with a Ruby version manager of some sort, such as rbenv
From there, you can install a version Ruby under your home directory using the version manager, and then tell RubyMine to point to it (Preferences -> Languages & Frameworks -> Ruby SDK and Gems -> [pick the version manager-installed Ruby you installed].
This may be a bit involved if you're just getting started, but it avoids polluting the gems folder of the system version of Ruby.

This is what worked for me:
Updated rubymine with toolbox to the newest version
Click "debug" on your app once you set up your configuration
Get the following error message:
Go to the problematic directory (in this case /Users/lizzie/.gem/ruby/2.7.0)
Click "Get Info" on the directory: 
Click the lock button on the bottom right and put in your password, give everyone read & write access, and finally click the action menu and select "Apply to enclosed folders":

Related

`gem install <package>` 404 Not Found, Error: Gem::RemoteFetcher::FetchError

I'm having a difficulty with RubyGem.
Environment
Windows 64-bit
Using Git-Bash in VSCode
Ruby 3.2.0 + devkit installed from rubyinstaller.org
Problem
run gem install bundler provides this error message:
$ gem install bundler -V
HEAD https://index.rubygems.org/
200 OK
GET https://index.rubygems.org/info/Kim/.local/share/gem/ruby/3.2.0
404 Not Found
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Not Found 404 (https://index.rubygems.org/info/Kim/.local/share/gem/ruby/3.2.0)
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/remote_fetcher.rb:232:in `fetch_http'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/remote_fetcher.rb:248:in `fetch_path'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/resolver/api_set.rb:105:in `versions'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/resolver/api_set.rb:56:in `find_all'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/resolver/composed_set.rb:54:in `block in find_all'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/resolver/composed_set.rb:53:in `map'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/resolver/composed_set.rb:53:in `find_all'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/resolver/best_set.rb:30:in `find_all'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/resolver/installer_set.rb:170:in `find_all'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/resolver/installer_set.rb:61:in `add_always_install'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/dependency_installer.rb:322:in `resolve_dependencies'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/commands/install_command.rb:201:in `install_gem'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/commands/install_command.rb:226:in `block in install_gems'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/commands/install_command.rb:219:in `each'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/commands/install_command.rb:219:in `install_gems'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/commands/install_command.rb:167:in `execute'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/command.rb:323:in `invoke_with_build_args'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/command_manager.rb:185:in `process_args'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/command_manager.rb:149:in `run'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/gem_runner.rb:51:in `run'
C:/Ruby31-x64/bin/gem:21:in `<main>'
run gem env provides this error message:
$ gem env
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown environment option [Kim/.local/share/gem/ruby/3.2.0]
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/commands/environment_command.rb:93:in `execute'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/command.rb:323:in `invoke_with_build_args'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/command_manager.rb:185:in `process_args'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/command_manager.rb:149:in `run'
C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/gem_runner.rb:51:in `run'
What could be the cause of this problem?
What steps can I follow to solve this issue?
Thanks.
These lines indicate that your shell environment is misconfigured:
GET https://index.rubygems.org/info/Kim/.local/share/gem/ruby/3.2.0
404 Not Found
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
bad response Not Found 404 (https://index.rubygems.org/info/Kim/.local/share/gem/ruby/3.2.0)
You should instead see this:
HEAD https://index.rubygems.org/
200 OK
GET https://index.rubygems.org/info/bundler
200 OK
This line also indicates a misconfiguration:
Unknown environment option [Kim/.local/share/gem/ruby/3.2.0]
This is most likely caused by the gemrc or .gemrc file having incorrect contents. The location of this file on Windows varies so I would recommend looking in the following locations for it:
%USERPROFILE% (typically C:\Users\<your username>
C:\ProgramData
C:\Ruby31-x64
If you can't find the file in any of those locations then perform a search of C:\ to find it.
Once you've found it you can either edit the file to remove the invalid values or you can delete it entirely. (or more preferably, rename it so that you can restore it if necessary)

Installing Ruby on Godaddy Shared Hosting

I'm trying to use Linuxbrew to manage my dependencies; however, when I attempt to install I receive an error.
Error: No such file or directory - /usr/local/bin/rub
I have attempted to install using the source files and running
./configur-prefix=$Home/env
make
make install
which gives the following report:
installing binary commands: /env/bin
/home/tmiles199/downloads/ruby-2.4.1/lib/fileutils.rb:226:in `mkdir': Permission denied # dir_s_mkdir - /env (Errno::EACCES)
from /home/tmiles199/downloads/ruby-2.4.1/lib/fileutils.rb:226:in `fu_mkdir'
from /home/tmiles199/downloads/ruby-2.4.1/lib/fileutils.rb:207:in `block (2 levels) in mkdir_p'
from /home/tmiles199/downloads/ruby-2.4.1/lib/fileutils.rb:205:in `reverse_each'
from /home/tmiles199/downloads/ruby-2.4.1/lib/fileutils.rb:205:in `block in mkdir_p'
from /home/tmiles199/downloads/ruby-2.4.1/lib/fileutils.rb:191:in `each'
from /home/tmiles199/downloads/ruby-2.4.1/lib/fileutils.rb:191:in `mkdir_p'
from ./tool/rbinstall.rb:194:in `makedirs'
from ./tool/rbinstall.rb:306:in `prepare'
from ./tool/rbinstall.rb:344:in `block in <main>'
from ./tool/rbinstall.rb:822:in `block in <main>'
from ./tool/rbinstall.rb:819:in `each'
from ./tool/rbinstall.rb:819:in `<main>'
make: *** [do-install-all] Error 1
Godaddy does not allow sudo or su access. The server info
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17)
I need Homebrew to install xz and glibc before I can install Ruby, or update the gcc version. Unfortunately, both produce the first error.
Could anyone help me install this package? My real endgoal is updating gcc through brew.
You don't have needed permissions to do that in the shared hosting:
in `mkdir': Permission denied # dir_s_mkdir - /env (Errno::EACCES)
When you try to create the directory, the installation fails.
You need a VPS, a dedicated server or a shared hosting preconfigurated.
I have found out a workaround for this issue to be able to install homebrew without root and sudo access.
Just follow the instruction on the Alternative Installation section of brew.sh and it will wonderfully work with no mayor issues at all.
This option will not work if you do not meet the minimum requirements regarding the glibc version.

Ruby on Rails (Errno::EACCES)

I am getting the following error whenever I type any command on all my rails applications. I working on a virtual machine in cloud 9. Any idea or guidance?
(master) $ bundle exec rspec spec/
/opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:541:in `read': Permission denied - /usr/libexec/openshift/cartridges/c9-0.1/root/lib/ruby/gems/specifications/multi_json-1.8.4.gemspec (Errno::EACCES)
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:541:in `load'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:269:in `block (2 levels) in _all'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:268:in `each'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:268:in `block in _all'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:267:in `each'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:267:in `_all'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/specification.rb:410:in `each'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/dependency.rb:216:in `find_all'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/dependency.rb:216:in `matching_specs'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/dependency.rb:238:in `to_specs'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems/dependency.rb:256:in `to_spec'
from /opt/rh/ruby193/root/usr/share/rubygems/rubygems.rb:1231:in `gem'
from /usr/libexec/openshift/cartridges/c9-0.1/root/lib/ruby/gems/bin/bundle:22:in `<main>'
It sounds like your gems were installed with sudo access, which your current user (web runner?) lack the right perms to see the Ruby install dir.
I can't quite say why the gems were installed to a path like /usr/libexec/openshift/cartridges — perhaps this is part of your cloud host's setup?
Do you boot your own rails server out of your instance? e.g. like you installed Unicorn, nginx, etc. on your own? If so, you can use rbenv to install a ruby and gemset to a local path over which you have full permission control.
If you don't have scenario #1 above, then the setup may be misconfigured by the host, and you should open a ticket.

I get error message:in `tr': invalid byte sequence in UTF-8 (ArgumentError) when I run: ruby dk.rb init

I have installed Ruby 1.92 in my computer, and would like to intall rails.
When I run: gem install rails, I get error message as below:
*D:\Ruby192\Devkit>gem install rails
*ERROR: Error installing rails:
The 'json' native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'**
Then I download DevKit 4.5.2 or DevKit 3.5 and try them both as:
D:\Ruby192\Devkit>ruby dk.rb init
I always get error message:
d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:175:in `tr': invalid byte sequence in UTF-8 (ArgumentError)
from d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:175:in `initialize'
from d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:233:in `exception'
from d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:233:in `raise'
from d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:233:in `check'
from d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:256:in `OpenKey'
from d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:387:in `open'
from d:/Ruby192/lib/ruby/1.9.1/win32/registry.rb:498:in `open'
from dk.rb:118:in `block in scan_for'
from dk.rb:116:in `each'
from dk.rb:116:in `scan_for'
from dk.rb:138:in `block in installed_rubies'
from dk.rb:138:in `collect'
from dk.rb:138:in `installed_rubies'
from dk.rb:146:in `init'
from dk.rb:313:in `run'
from dk.rb:332:in `<main>'
Have you guys got any suggestion on the problem?
I have encountered the same situation. I think that you may want to install json library. You should use msys.bat and install json on this terminal.
Execute msys.bat in a DevKit directory -> it invokes a new terminal.
gem install json on this terminal.
You can continue gem install rails.
The problem was solved for me by clearing the LANG environment variable first:
set LANG=
ruby dk.rb init
The idea comes from this question on the RubyInstaller Google Group.

RoR Bundler problem

I installed everything from the bottom up and thought it was working fine until I ran a bundle install
Has anyone ever seen this? Any ideas? Please help. Thanks.
bundle install
Fetching source index for http://rubygems.org/
/usr/local/lib/ruby/1.9.1/rubygems/format.rb:38:in `from_file_by_path': Cannot load gem at [/usr/local/lib/ruby/gems/1.9.1/cache/rake-0.8.7.gem] in /home/ec2-user/anotherApp (Gem::Exception)
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/source.rb:73:in `fetch'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/installer.rb:45:in `block in run'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `block in each'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/spec_set.rb:12:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/installer.rb:44:in `run'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/installer.rb:8:in `install'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/cli.rb:226:in `install'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vendor/thor/task.rb:22:in `run'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vendor/thor.rb:246:in `dispatch'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/vendor/thor/base.rb:389:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/bin/bundle:13:in `<top (required)>'
from /usr/local/bin/bundle:19:in `load'
from /usr/local/bin/bundle:19:in `<main>'
If you install Ruby 1.9.2-x from source it still installs the gems to /usr/local/lib/ruby/gems/1.9.1/... which is a bit of a WTF (relevant). I too got this error but it can also be caused by a permissions issue. So try running the command again as root (assuming you're running into this on a *nix system). Yes, that is not ideal however you may find it works and at least you can keep on going on the path to figuring things out (and it's all in a test VM anyway, right?).
It's not recommended to use Ruby 1.9.1 with Rails. Better 1.8.7 or 1.9.2, see http://rubyonrails.org/download. Looks like you use the Debian/Ubuntu Ruby. 1.8.7 is available and usable in Debian/Ubuntu, install the ruby-full meta package via apt. Or compile Ruby 1.9.2 directly or via the Ruby Version Manager (rvm). Do not install rubygems via apt.

Resources