Uninitialized constant error using Ruby in RubyMine - ruby

Has anyone used RubyMine who could help me out?
I am new to RubyMine, and when I create my first project and add a few classes and wire them together for a simple meaningless application I am getting this error:
"uninitialized constant RubyApp (NameError)"
But when I take all the classes and put them in one file then run it, it runs fine.
What am I missing about using RubyMine here?
Thanks for the help.

Is "RubyApp" one of your classes?
If so, it sounds like you're not requiring the other ruby files you're creating.
RubyMine pretty much doesn't get in your way at all, although it does like having gems 'attached' to the project.

Not sure if this applies to your case, since I've only run into this issue with gems. But, Rubymine requires you to link the gems your using and what not into your project settings for things to work. At least that is how I remember it when I tried it out.

Related

How to get Processing to work on Cloud9 using Ruby language?

I am currently working on a personal project using the Ruby language in Cloud9 IDE. Recently, I came across an environment/programming language called Processing. My goals is to make Processing available for my use in Cloud9 IDE.
I am a complete novice and have no clue what I am doing. I followed directions from the following website: Directions for setting up Processing
I entered the following commands into Cloud9's terminal:
rvm install jruby
rvm use jruby
gem install ruby-processing
PROCESSING_ROOT: "/Applications/Processing.app/Contents/Java"
Entering in PROCESSING_ROOT: "/Applications/Processing.app/Contents/Java"
outputted message bash: PROCESSING_ROOT:: command not found
I wasn't too surprised by this, since the last entry probably needs information specific to my setup. Here are my questions:
1.) Are these directions correct for what I am trying to do? (get Processing to work in Cloud9 IDE). If they are not correct, can someone please point me to the correct directions, or give me directions?
2.) If these directions are correct, how can I successfully finish the last step? I tried running DrawRuby.rb, a simple program copied from the internet that supposedly made use of Processing. When I ran the code, the message "You need to set PROCESSING_ROOT in ~/.rpsrc" appeared. I am not sure if this piece of information is relevant or not, but I figured I would add it.
This is where I am at, and I am completely stuck. If someone could give me some help, I would be very grateful. Also, please make your explanation easy to understand. I am relatively new to the programming world, and may not necessarily understand terminology or how things should work.
Cheers!
*** Edit: I created a new workspace in Cloud9 IDE and tried Jed's suggestion. This is what happened:echo 'PROCESSING_ROOT: "/Applications/Processing.app/Contents/Java"' > ~/.rpsrc
:~/workspace $ rp5 run Draw.rb
WARNING: you need to set PROCESSING_ROOT in ~/.rp5rc
NameError: uninitialized constant Processing::RP_CONFIG
Did you mean? Config
RbConfig
const_missing at org/jruby/RubyModule.java:3344
spin_up at /usr/local/rvm/gems/jruby-9.1.7.0/gems/ruby-processing-2.7.1/lib/ruby-processing/runner.rb:188
run at /usr/local/rvm/gems/jruby-9.1.7.0/gems/ruby-processing-2.7.1/lib/ruby-processing/runner.rb:105
execute! at /usr/local/rvm/gems/jruby-9.1.7.0/gems/ruby-processing-2.7.1/lib/ruby-processing/runner.rb:67
execute at /usr/local/rvm/gems/jruby-9.1.7.0/gems/ruby-processing-2.7.1/lib/ruby-processing/runner.rb:61
<main> at /usr/local/rvm/gems/jruby-9.1.7.0/gems/ruby-processing-2.7.1/bin/rp5:10
load at org/jruby/RubyKernel.java:979
<eval> at /usr/local/rvm/gems/jruby-9.1.7.0/bin/rp5:1
eval at org/jruby/RubyKernel.java:1000
<main> at /usr/local/rvm/gems/jruby-9.1.7.0/bin/jruby_executable_hooks:15
You need to add a file to your home directory (~/) called .rpsrc and then add that environmental setting (PROCESSING_ROOT) to your file. The following should work from the command line in your cloud9 environment:
echo 'PROCESSING_ROOT: "/Applications/Processing.app/Contents/Java"' > ~/.rpsrc
I know it might be a bit late for you but ruby-processing is now deprecated, and will only work with processing-2.2.1. For processing-3.3.7 use either JRubyArt or propane latter does not even require processing install.

Intellij IDEA Ruby Language Level

I got a Rails Project in intellij idea but somehow the language level seems to be set on 1.8. I got the following configuration:
But it still shows the following error:
Am I missing something? When I had problems with the colon syntax before, it was always the language level.
Thanks,
Robin
I still don't know what the problem exactly was but I guess it had something todo with binstubs. What I did:
I opened the project in RubyMine, where I got the warning: "no ruby interpreter configured for the project", though the correct rvm ruby was selected
I deleted the .idea folder and the bin folder
I opened the project in RubyMine again, this time it correctly recognised the rvm ruby
I opened the project in Intellij IDEA, everything works fine here too.
The answer is given by rweng:
Remove .idea folder
File/New/ProjectFromExistingSources
Maybe deleting the module and recreating the same might also help

TestFirst.org Learn_ruby rake and depreciation warnings :should and :expect syntax

After many searches via Google I'm ready to get some input from the community. I'm trying to apply for App Academy in San Francisco and one of the required pre-work is TestFirst's Learn_ruby. I original had this configured on a Linux VM on my windows box. It worked very well. When I ran rake it would list one problem at a time; the text was is helpful colors; and the output was very condensed so I only got what I needed to read. I've recently wiped and configured my system as a dual boot Xubuntu 14.04/ Windows and the VM I once had is long gone. I worked to get Ruby setup in my linux vm just as I had done in the VM.
My problem now is when I run rake on my projects I get the same depreciation warning:
Deprecation Warnings:
Using should from rspec-expectations' old :should syntax without
explicitly enabling the syntax is deprecated. Use the new :expect
syntax or explicitly enable :should instead. Called from
/home/kaji/Projects/learn_ruby/05_silly_blocks/silly_blocks_spec.rb:25:in
`block (3 levels) in '.
After googling this back and forth I understand for the most part what the error is telling me. And I've even found a solution to get it to go away. Thanks to this post: RSpec's New Expectation Syntax, I was able to find a syntax to make the warning go away. (basicly had to change blah.should == # to expect(blah()).to eq(#) inside the *_spec.rb file. This seems to make the warning happy. However I still see signs that I have another problem.
The output isn't as 'friendly' as it was when I was on my VM. It's not in color; it dumps all the errors at once. What I enjoyed the most about learn_ruby was it gave me one objective at a time with minimal output. Now i have to scroll up quite a ways just to see what my issues are.
I've tired removing RVM completely and all gems and reinstalling to see if I could resolve this. No dice. I'm such a Ruby Noobie i'm a little overwhelmed with all this. I'd like to just get back to learning the basics but this has been troubling me for over a week. Has anyone had this problem/fix the except
I've also tried removing the rpsec ~<=2.0 from the Rakefile. I'm using ruby -v 2.1.2, rails 4.1.1 and i have RSpec 3.0.0, 2.99.0, 2.0.0. I even tried finding a tutorial on changing the syntax but it was real confusing as it introduced lots of Ruby concepts I have no idea on. At that point I feel like I'm over my head and there is something simple I'm missing.
Hope I provided enough info for assistance.
I hope I'm answering the correct question, since you seem to have figured out the one in the title (i.e. the preferred syntax having changed from blah.should to expect(blah).to). It would help if you changed the title to reflect the actual question.
RSpec.configure do |config|
config.fail_fast = true
config.color_enabled = true
}
will make RSpec fail at first error, rather than after running all tests, and enable the colours, for that one file.
Or you can run rspec with rspec --fail-fast --color.
Alternately, you can put this in $HOME/.rspec so it always does it:
--fail-fast
--color

How to traverse through Source code only using debugger - Rails 3.2.13

In my Rails app, using Ruby 2.0.0-p0 and Rails 3.2.13, I also use the gem debugger for debugging purpose. If I have to debug an area in my source code, for e.g. a controller method, I will put debugger inbetween and when I execute the action, it will go to the source code and then travserse through the framework code a lot and that really mess-up the normal debugging. I can see many commands through help, but don't know how to handle with that.
I just want to traverse through the source code only..
Please help me to have a solution. Thanks :)-
Use byebug instead. It was created to overcome debugger's problems with ruby-2.0.0, like the one that makes it "step" when you use command "next", unexpectedly leading you to framework sources.
Disclaimer: I'm byebug's author

Ruby problem(bug)- in rake gem

i am running ruby 1.9.2p0 on rails on windows OS with rubymine 3.1.1.
i use it for גseveral weeks.
a few days ago- i tried to run my project from rubymine and the console notification was:
"Could not find rake-0.8.7 in any of the sources
Process finished with exit code 7"
i googled it and i found reference to this problem in several places. the solution repeated most often was to delete the non-versioned "rake.gemspec" file.
i tried this solution but the problem is not resolved, it still says the same notification.
i trying to solve this problem for several days!!!
please help me if you know how!!!
thanks a lot in advanced!
Asaf,
I've had literally hours of frustration dealing with similar problems. The solution can be a challenge to track down, because there are numerous reasons you could be having the problem. I'm no expert myself, but I'll try to pass on some of what I've learned.
First, you mentioned getting an error about Rake, but didn't mention that you had tried to actually run Rake. Are you getting the error upon loading up RubyMine or specifically after running a Rake command?
Next, if you are running a Rake command and getting an error, you should take note that WHERE you run the command from is pretty important. For example, if you keep a Terminal window open like I do, and run the Rake command from Terminal, you won't necessarily get the same results you would get by running Rake from RubyMine itself. The reason for this was not self-evident when I first started with RubyMine, but I think it comes down to this:
The Ruby SDK and Gems preferences in RubyMine should be determining what types of dependency errors you get from within RubyMine. So you might start by looking there to see if there are any dependency errors. Next, I would guess that you're running RVM? Please be aware that it is completely possible to be using one RVM set in RubyMine (check the Ruby Interpreter in SDK and Gems Preferences to see which one you're using) and an entirely different RVM in Terminal (the command "RVM info" should get you the version you're using). If those don't match, you could very well get different results from both RubyMine and Terminal, even when running exactly the same commands.
My solution to this problem was to carefully ensure that both of my environments matched. I think you can set RVM defaults by typing "rvm default" plus the version you want to default to. That way both your Terminal and RubyMine environments match.
Lastly, be aware that RubyMine allows more than one version of a Gem to be installed at the same time. So, if you're getting an error that a Gem is failing because some dependency requires a specific version, you can tell RubyMine to install multiple versions. Do this thru the SDK manager, select the Gem, then click "Select Versions".
Hopefully some of this information applies to your issue. I sort of did the shotgun approach, because I'm not really sure what is causing your error, but maybe some of this can put you on the right path. One final note would be this: Use your Gemfile to control Gem versions, if need be. I've spent hours of frustration over broken dependencies, only to discover that the reason for the break was me telling RubyMine to update all my Gems to the latest version. The latest version of a particular Gem isn't necessarily backwards compatible with previous versions, and blindly updating Gems can cause huge problems.
Asaf, you should delete rake.gemspec and run gem install rake to get problem fixed

Resources