No Rspec gem found in sdk through IntelliJ - ruby

I am trying to get a project to work that was created through RubyMine. I have an ultimate version of IntelliJ and would rather use that with the Ruby plugin to run these tests.
However when I attempt to run I get an error saying "No Rspec gem found in SDK". I havent
My Gem environment looks like this:
mac:~ cmietzner$ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.7
- RUBY VERSION: 2.2.1 (2015-02-26 patchlevel 85) [x86_64-darwin14]
- INSTALLATION DIRECTORY: /Users/colemietzner/.rvm/gems/ruby-2.2.1
- RUBY EXECUTABLE: /Users/colemietzner/.rvm/rubies/ruby-2.2.1/bin/ruby
- EXECUTABLE DIRECTORY: /Users/colemietzner/.rvm/gems/ruby-2.2.1/bin
- SPEC CACHE DIRECTORY: /Users/colemietzner/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/colemietzner/.rvm/gems/ruby-2.2.1
- /Users/colemietzner/.rvm/gems/ruby-2.2.1#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/colemietzner/.rvm/gems/ruby-2.2.1/bin
- /Users/colemietzner/.rvm/gems/ruby-2.2.1#global/bin
- /Users/colemietzner/.rvm/rubies/ruby-2.2.1/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/git/bin
- /Users/colemietzner/.rvm/bin

Your problem is that IntelliJ created your mobile as a Java-oriented module. One can tell by the little blue square next to the module name.
This fixed it for me:
Open Project Structure
Click on Modules under Project Settings
Delete the module (via -)
Add a new module, and choose Ruby (or rails, or whatever you need)

I realise this is an old question but I ran into the same problem and solved it as follows:
The Problem:
In the intelliJ configuration screen shown in the screenshot above (found in "Run" > "edit configurations"), you can see the configuration is trying to "Choose the SDK from the module". And of course there are no Ruby binaries inside the module (the project directory) so it throws the "No SDK found" error.
The solution:
(Assuming all the appropriate gems have been $ bundle install'd) I found the solution was to select "Use other SDK and 'rspec' gem:" and choose the appropriate SDK. BUT to ensure this applies to the whole project, I replicated this change in "Defaults" configuration for both Ruby and RSpec.
e.g for Ruby settings:
and for RSpec settings:

Related

Have Twurl installed, but I can't access it

I have installed Twurl but for some reason I still can't use it. I believe I have it installed because it shows up when I type the ls command. Then I am able to navigate to the folder that Twurl is contained in. However, I am not able to go into the Twurl folder because it says it is not a directory. I am able to use the command open twurl, which opens up a seperate terminal window with a lot of information about Twurl, but I can't type anything. One other thing, when I try and run twurl authorize I get this response: twurl: command not found So my question is, how do I go about getting twurl to work now? Such that I can run the twurl authorize command.
gem env output:
- RUBYGEMS VERSION: 3.1.4
- RUBY VERSION: 2.7.2 (2020-10-01 patchlevel 137) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.7.0
- USER INSTALLATION DIRECTORY: /Users/CharlieBagin/.gem/ruby/2.7.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/2.7.0/bin
- SPEC CACHE DIRECTORY: /Users/CharlieBagin/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.7.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.7.0
- /Users/CharlieBagin/.gem/ruby/2.7.0
- /usr/local/Cellar/ruby/2.7.2/lib/ruby/gems/2.7.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/opt/ruby/bin
- /Users/CharlieBagin/anaconda3/bin
- /Library/Frameworks/Python.framework/Versions/3.6/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
I think I might have installed it in two places. I originally used gem install twurl, but then it wasn't working and I was trying some things and used bundler to install at some point too.

Is there a way to define an alias that executes a bin from a specific folder in MacOS?

I am currently using a Macbook Pro running MacOS Mojave 10.14.3. I have recently gotten into ruby programming but find their whole gem package management a little confusing. When i gem install a package, it installs it in my /usr/local/lib/ruby/gems/2.6.0/bin folder and if I want to execute a gem or get a gem version, for example the solargraph gem, I must type a command: /usr/local/lib/ruby/gems/2.6.0/bin/solargraph -v. I was wondering if there is way for me to define an alias for the path /usr/local/lib/ruby/gems/2.6.0/bin so that I could type something like gemexec solargraph -v which would achieve the same result as /usr/local/lib/ruby/gems/2.6.0/bin/solargraph -v. Thanks for your help. BTW I am using the ZSH shell.
You can make a function that will do this for you and place it in your .zshrc file.
function gemexec() {
/usr/local/lib/ruby/gems/2.6.0/bin/"$1"
}
You can use the fact that Ruby 'install' the binary to central bin directory located at /usr/local/lib/ruby/gems/RUBY_VERSION/bin.
Use gem environment to determine your path:
gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.7.7
- RUBY VERSION: 2.5.3 (2018-10-18 patchlevel 105) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.5.0
- USER INSTALLATION DIRECTORY: /Users/alice/.gem/ruby/2.5.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/2.5.0/bin
- SPEC CACHE DIRECTORY: /Users/alice/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.5.3_1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.5.0
- /Users/alice/.gem/ruby/2.5.0
- /usr/local/Cellar/ruby/2.5.3_1/lib/ruby/gems/2.5.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/opt/ruby/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
Then, you can add ruby bin path into your global bin path and to get what you want -
PATH="/usr/local/lib/ruby/gems/2.5.0/bin:$PATH"
solargraph -v
0.31.3
Finally, to make zsh to use this PATH every time you open a shell, add this line into your .zsh_rc file -
echo PATH="/usr/local/lib/ruby/gems/2.5.0/bin:$PATH" >> ~/.zshrc

Why am I Getting "Error Copying Gems" in Rubymine while setting "Ruby SDK and Gems" to use Vagrant

I'm trying to configure Rubymine 6.3.3 to use the Ruby SDK and gems from my vagrant virtual machine.
Rubymine (at least, 6.3.3) has built-in support for this. To set it up, I do the following:
Click on "File" -> "Settings"
Click the "Ruby SDK and Gems" section
Add a new remote by clicking the "+" add option -> "New Remote"
Click the "Fill from Vagrant Config" button in the "Configure Remote Ruby Interpreter" dialog, which defaults to the following settings (I override the default keypair settings to instead use a password):
Host: 127.0.0.1
Port: 2222
User name: vagrant
Auth type: password
Password: vagrant
Ruby interpreter path: /usr/bin/ruby (verified with $ which ruby on guest OS)
Test the connection, by clicking the "Test connection" button, which is successful
Click "OK" to finish
When downloading gems, it recursively goes deeper and deeper into the /usr/bin/X11/ directory like:
/usr/bin/X11/gtk-launch
/usr/bin/X11/X11/gtk-launch
/usr/bin/X11/X11/X11/gtk-launch
/usr/bin/X11/X11/X11/X11/gtk-launch
After getting stuck in that loop for a while, it gets stuck in a loop of downloading various gems, and creating a folder (which I cannot see what folder because it flashes too quickly).
It eventually ends with an "Error Copying Gems" dialogue stating:
Could not copy "sftp://127.0.0.1:2222/usr/bin/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/x86_64-linux-gnu-gcc-nm" to "file:///home/billy/.RubyMine60/system/ruby_stubs/-828640210/170586877/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/X11/x86_64-linux-gnu-gcc-nm".
Upon clicking OK, it gets stuck in another loop of attempts at downloading the gems, and after clicking OK for a second time to the same error message, it exits, and just shows my new "Ruby SDK and Gems" configuration with no gems.
The virtual machine has the following versions installed:
vagrant#rails-dev-box:/vagrant $ ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux-gnu]
vagrant#rails-dev-box:/vagrant/ $ bundle -v
Bundler version 1.11.2
vagrant#rails-dev-box:/vagrant/ $ gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5.1
- RUBY VERSION: 2.2.4 (2015-12-16 patchlevel 230) [x86_64-linux-gnu]
- INSTALLATION DIRECTORY: /var/lib/gems/2.2.0
- RUBY EXECUTABLE: /usr/bin/ruby2.2
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /home/vagrant/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/2.2.0
- /home/vagrant/.gem/ruby/2.2.0
- /usr/share/rubygems-integration/2.2.0
- /usr/share/rubygems-integration/all
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
Why can Rubymine not configure these gems properly?
The problem is the symbolic link from /usr/bin/X11 => /usr/bin/ that Ubuntu has. This sent RubyMine down a recursive /usr/bin/X11/X11/X11/" path trying to find gems, finally resulting in the error.
Since the OS is only being used as a virtual machine through Vagrant, I deleted the /usr/bin/X11 symbolic link. This allowed RubyMine to find the gems and everything worked as expected.
Note: There is a valid reason for the existence of this symbolic link. This answer is simply a workaround for RubyMine versions before 7.0, as this peculiar bug was fixed in RubyMine 7.0.

Textmate + RVM + Rake = Rake not using expected gem environment

I am using:
TextMate: version 2.0-alpha.9511
rvm: 1.25.15 (stable)
ruby: version 2.1.0p0
oh-my-zshell: 5.0.2
Mac OS X: 10.9.1 (Mavericks)
I have rvm and textmate set up to use
TM_RUBY=/Users/<myuser>/.rvm/bin/rvm-auto-ruby
The problem:
when I try to run my rake tasks using the rake bundle in textmate, I get some errors about the file not loading: "cannot load such file -- rubocop/rake_task"
The clue:
I changed my rakefile so that it simply reports the "gem env" for the default task.
When I then run the task, I see a completely different gem environment, than I would see if I used rake at the terminal command line.
RakeMate v2.0.0
>>> /Users/Johno/Projects/puzzles/triangle/Rakefile
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.3
- RUBY VERSION: 2.0.0 (2013-06-27 patchlevel 247) [universal.x86_64-darwin13]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-13
- GEM PATHS:
- /Library/Ruby/Gems/2.0.0
- /Users/Johno/.gem/ruby/2.0.0
- /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
Whereas I see this when running
$ gem env
in my terminal, for my project
RubyGems Environment:
- RUBYGEMS VERSION: 2.2.0.rc.1
- RUBY VERSION: 2.1.0 (2013-12-25 patchlevel 0) [x86_64-darwin12.0]
- INSTALLATION DIRECTORY: /Users/Johno/.rvm/gems/ruby-2.1.0#puzzles
- RUBY EXECUTABLE: /Users/Johno/.rvm/rubies/ruby-2.1.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/Johno/.rvm/gems/ruby-2.1.0#puzzles/bin
- SPEC CACHE DIRECTORY: /Users/Johno/.gem/specs
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /Users/Johno/.rvm/gems/ruby-2.1.0#puzzles
- /Users/Johno/.rvm/gems/ruby-2.1.0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/Johno/.rvm/gems/ruby-2.1.0#puzzles/bin
- /Users/Johno/.rvm/gems/ruby-2.1.0#global/bin
- /Users/Johno/.rvm/rubies/ruby-2.1.0/bin
- /Users/Johno/.rvm/bin
- /usr/local/bin
- /Users/Johno/Projects/Scripts/Ruby
- /Users/Johno/Projects/Scripts/bash
- /Users/Johno/Projects/Scripts/perl
- /Users/Johno/Projects/Scripts/Geek Tool
- /usr/bin
- /bin
I suspect that textmate is trying to use the "wrong" rake, or failing to set up the environment properly.
I think the problem may lie in the ruby bundle command from text mate:
#!/usr/bin/env bash
export RUBYLIB="$TM_BUNDLE_SUPPORT/RakeMate${RUBYLIB:+:$RUBYLIB}"
export TM_RAKE=$(which "${TM_RAKE:-rake}")
"/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby" -- "$TM_BUNDLE_SUPPORT/RakeMate/rake_mate.rb"
It appears to be using a specific ruby (1.8) rather than the rvm project specific ruby
Does anyone have a suggestion as to how to resolve this?
Thank you,
John Schank
Followed the advice to set TM_RAKE and it didn't help.
I tried both the suggested setting, and using the results of which rake
/Users/Johno/.rvm/gems/ruby-2.1.0#puzzles/bin/rake
When using my TM_RAKE, is get a different error
RakeMate v2.0.0
>>> /Users/Johno/Projects/puzzles/triangle/Rakefile
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'rake' (>= 0) among 5 total gem(s) (Gem::LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:307:in `to_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /Users/Johno/.rvm/gems/ruby-2.1.0#puzzles/bin/rake:22:in `<main>'
This happens to be the same error I get when I try to use the rubocop.tmbundle
It still looks to me like the gem environment is not being passed to the child process.
I solved my own problem.
Here are the details for anyone else who has this problem...
First, the answer in this question TextMate, rvm and TM_RUBY
is almost perfect.
I had to create a textmate_ruby, and a textmate_rake script, and reference them in the variables in text mate: TM_RUBY, and TM_RAKE.
Second, since I'm using zsh, I had to change the shebang line in the textmate_xxx scripts to use zsh.
Finally, the key that helped me arrive at the correct solution is that I modified my project rakefile to :
task :default do
system "gem env"
system "ruby --version"
system "pwd"
system "printenv"
end
Then when I ran the rake task in textmate, it would dump the current values of my environment, ruby version, current directory, and gem environment. This really helped to see what was going on.
It seems that TextMate is still using your system rake instead of rvm's.
Try to set TM_RAKE in addition to TM_RUBY:
TM_RAKE=$HOME/.rvm/bin/rake
This also applies to rbenv, where you would set TM_RAKE to $HOME/.rbenv/shims/rake.

Ruby gem LoadError - rubygems/defaults/operating_system

I've installed ruby 1.8.6 p368 and gems 1.3.4 as well as required libraries like zlib, ssl or readline on my winxp sp3 box.
The problem is, when I now try to use some gem, I get the following error:
Exception `LoadError' at D:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:1112 - no su
ch file to load -- rubygems/defaults/operating_system
Exception `LoadError' at D:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.
rb:31 - no such file to load -- mysql
Seems like it makes sense to start with fixing the missing "rubygems/defaults/operating_system" file. How can I do that? TIA
PS:
gem env is
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.4
- RUBY VERSION: 1.8.6 (2009-03-31 patchlevel 368) [i386-mswin32]
- INSTALLATION DIRECTORY: D:/ruby/lib/ruby/gems/1.8
- RUBY EXECUTABLE: D:/ruby/bin/ruby.exe
- EXECUTABLE DIRECTORY: D:/ruby/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86-mswin32-60
- GEM PATHS:
- D:/ruby/lib/ruby/gems/1.8
- C:/Documents and Settings/fluffy/.gem/ruby/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://gems.rubyforge.org/
Were you running using -d? If so, this email reckons that it's displaying exceptions even when they're rescued.
It looks like you need the mysql gem too.
The following error
Exception 'LoadError' at D:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:1112 - no such file to load -- rubygems/defaults/operating_system
Can relate to either
a corrupt installation (check the rubygems.rb file and make sure it requires 'rubygems/defaults/operating_system'. If it does, check to see if it exists) or
you're trying to run a 2.3.x app while the server is still configured to using Rails 2.1.x
I hope this helps. If not, let me know.
Have you tried InstantRails? It has rails/apache/mysql in a nice package and worked out of the box on every XP box I tried.
I also install NetBeans as dev environment and just point it to InstantRails "bin/ruby" binary.

Resources