I've been using this guide
Whenever I go to import the module I get this screen:
I used the following file path, maybe this is whats wrong?
/usr/local/Cellar/ruby-build/20160130/share/ruby-build/2.3.0
And got this error:
I'd appreciate any ideas anyone might have, i've been trying get this working all night!
I ran into this problem with Intellij IDEA 2020.2. It took a while to resolve because the Intellij documentation seems to be missing one critical piece.
When you first open a project in IDEA, it assumes all your code is part of a Java module. With that module in place you cannot set a Ruby SDK at the module level. There's no option to do because the existing module is configured as Java.
Here's a screenshot of my example project with the default Java module. Notice the icon is a folder with a blue rectangle in the lower, right corner.
Here's what I had to do.
Open the Project Structure dialog (File | Project Structure).
In the Modules settings, highlight the top-level project module and click the delete button (looks like a minus sign).
Click the plus sign to add a new module.
From the pop-up click "New Module".
In the "New Module" pop-up select Ruby and the correct Module SDK (e.g. rbenv: 2.5.0)
When you are prompted to enter the Module name, Content root, and Module file location, make sure the directories are set to your project's root. When I entered the module name it appended the name to the project's root directory which is probably not what you want.
Once you've done that the module should appear with a Ruby icon on it and the rest should work as documented here: https://www.jetbrains.com/help/idea/configuring-language-interpreter.html
Here's a screenshot of my new Ruby module. You can see the Ruby icon replaced the blue rectangle.
I hope this saves you some time!
In order to set Ruby SDK for your project in IDEA you need to go to File | Project Structure | Project Settings and set project and module SDK.
Olivia is correct, the "Project Structure..." (Mac shortcut Cmd+;) is the dialog for configuring the IDE to use different ruby installations.
The first requirement is that the ruby manager (chruby, rbenv, rvm) is configured properly.
Another concern is exactly where and how jetbrains expects the ruby installation to be organized. I wonder if Intellij is compatible with the way ruby-install lays out ruby? That's the one I used with chruby. I could not make it work.
The posted url to Opening Rails projects in IntelliJ IDEA helped me feel the most confidence that we are on the right track. :)
At the time, I was failing to get Intellij configured due to fact the gem files were not seen by the IDE. All but about 4 gems in my project's Gemfile was being highlighted as having an SDK problem.
To end this, I stopped using chruby and ruby-install. I am not blaming chruby, however I could not make the chruby system work properly with the IDE. It worked fine in the shell. Note, I am a previous user of rvm and rbenv. Switching back to rbenv, now. Note that I've also stopped using ruby-build directly.
Instead, I built the first ruby version directly from rbenv:
rbenv install 2.3.1
Next, I created the .ruby-version file in the root of my rails project directory by running:
rbenv local 2.3.1
To help with any confusion regarding the minimum support needed in the shell startup scripts. Do not alter PATH at all. Place the following in your shell startup script system, whatever that may be:
# rbenv config in my .bash_profile
# --------------------------------
if which rbenv > /dev/null; then
eval "$(rbenv init -)";
fi
With the prerequisites out of the way...
I recommend doing the project import in the same way described in the jetbrains tutorial Opening Rails projects in IntelliJ IDEA.
In the first screenshot from thesowismine, I see two dialogs for different purposes that are simultaneously open. Unless I am mistaken, one of those dialogs should have received its info and closed before going forward, at least during the wizard-like process. Perhaps this was done and that dialog was reloaded later?
In any event, that is not where the Ruby SDK is associated to a Rails project. The screenshot indicates the User is browsing around the brew Cellar, which may indicate two things.
Ruby was installed with a brew install <version> command; I installed ruby by calling the rbenv ecosystem.
That particular dialog is for informing the IDE about the Rails project folder, not the Ruby kit.
Assuming the first dialog is provided with the root directory of the Rails app and next is clicked; then in the second dialog, I change nothing and click next. The 3rd dialog is where I confirm the project directory is correct and I can assign a more elaborate name (which is displayed in the IDE's project menu). Clicking next may prompt you to write over the ".idea/" directory. Say yes. The next dialog confirms that sources were found. Click next. Now Frameworks begin to be detected assuming the Ruby Manager is setup correctly. Click Finish.
Now, goto the "Project Structure..." dialog to set the SDK.
Before or after setting the SDK, go to the the project directory of your Rails project, run:
gem install bundle
bundle install
This will install all the gems your project requires including the rails gem, as presumably it is listed in your Gemfile.
Note that gemsets do not come up, here. In this config, the set of gems are associated to a particular Ruby installation. Bundler is your friend.
Languages & Frameworks > Ruby SDK and Gems
I was able to solve this by doing:
Preferences | Plugins | Install JetBrains plugin
Related
While navigating through http://installfest.railsbridge.org/installfest/linux I made it to step 4 and instead of rvm install 2.3 I used rvm install 2.4.4 in the Ubuntu command prompt and everything ran fine. Once output was finished, the last two lines said: Install of ruby-2.4.4 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri What do you fine people think? Build or not? The above link is meant to be part of an installation process for The Odin Project, which is just a free online web dev course if that helps put things into perspective.
I use RubyMine. When I'm curious about a method, such as render, I put the text caret on it and hit Control+B. RubyMine takes me to the method's definition, where I can read the comment which generates that documentation.
I always build Ruby and Gems with full documentation, and I never bother to read their output...
Issue
I am using xray-rails gem in a rails app and want it to open rubymine to the correct file when I click it in the browser. It was unclear how to configure this. xray-rails gem uses open3 to open the file in the editor.
Solution
Prerequisite: Follow the instructions for setting up rubymine to be callable from the commandline found in Running RubyMine as a Diff or Merge Command Line Tool
NOTE: This is also a handy use of rubymine, allowing it to perform diffs between files. Nice bonus for researching a solution to my problem.
Create ~/.xrayconfig with content...
:editor: mine
NOTE: mine is the name of the script created in the prerequisite steps. If you named your script something different, use that name in place of mine.
Now when you start xray-rails in your browser and click, the corresponding file will open in rubymine.
After importing an existing project into RubyMine, I encountered "Rails server launcher wasn't found in the project" when I Run/Edit Configuration.
I've checked this Cannot start the debugger in Rubymine. Rails server launcher wasn't found in project, but deleting the .idea directory and re-open is not helpful.
I can rails server in the Terminal successfully and the rails server runs. So I guess it's likely a RubyMine related thing.
Thanks,
Allen
The easiest way to fix it:
Close project
Remove .idea folder from project folder
Open project
Bingo!
NOTE: this workaround seems to no longer work with 2017.2. See RUBY-20144
I upgraded from RubyMine to IntelliJ Ultimate IDE 2017.1.5 and I encountered the same error "Run Configuration Error: Rails server launcher wasn't found in project". I was using Ruby v2.4.0 with Rails 5.0.2.
It took me an entire day to solve the issue, so I've written a detailed explanation with screenshots to guide others.
It occurred when I tried to Run or Debug my Rails server from within IntelliJ.
Other solutions also didn't fix the error. I tried deleting my .idea/ folder, trying different Ruby or Rails versions (i.e. Ruby v2.3.0 or latest Rails 5.1.2), and even starting a brand new project from scratch. But I could run the Rails server fine using Terminal (outside the IDE) with rails s.
SOLUTION approach:
First I opened Run > Edit Configurations but "Choose SDK from module" didn't have any Project Modules available to select from the drop-down, so I had to create one as follows:
I went to File > Project Structure
Then I clicked Modules, and clicked the icon "+", and selected "Import Module".
Then I navigated to my Rails project's root directory "'/Users/my_username/code/apps/_murmur/skag_server_rails" and clicked Open, which displayed the following.
I then selected "Create module from existing sources" and clicked "Next", and it showed the following, with a blue checkbox shown next to my Rails project root directory that it found, so I clicked "Next" again:
It then showed the following window, and I clicked "Finish".
I'd now finished importing the Rails project I was working on as a Module, and it showed the following, so I clicked "Ok", as I was now ready to try and run my Rails server again:
So I went back to Run > Edit Configurations window and click on "Rails > skag" where I could now use "Choose SDK from module" since there was now my "skag_server_rails" Module available in the drop-down that I just created, and no errors were apparent, as shown below:
I was then able to click Ok to save the Run/Edit Config
I was then able to run the server Run > Run, which displayed:
I was then able to successfully open the Rails app in the browser open http://localhost:3000
But then when I tried to Run > Debug so I could debug using breakpoints, it gave me the following errors:
I solved this by running the following in the Terminal (outside the IDE):
gem install debase --pre
gem install ruby-debug-ide
Then finally I could run Run > Debug and it allowed me to trigger breakpoints as shown below:
Important Note:
The initial approach that I took that DID NOT end up fixing the error involved choosing to use "Use other SDK" within the Run > Edit Configurations window to load my Ruby Gemset into the debug configuration (instead of using a Module).
UPDATE: I encountered the same error again more recently on 2nd September 2017 and followed these steps to overcome it:
Go to Menu > File > Project Structure > Project Settings > Modules > Click "+" and select "New Module"
Select "Ruby on Rails" from the left hand side list
Choose for "Module SDK" label your "RVM: ruby-2.4.1 []"
Click for "Rails Version" label the "Install Rails Gem..." drop-down
Select a Rails version for it to download and wait (i.e. 5.0.0)
Do not select a Rails version that causes the tooltip "This version is not fully supported" to appear below (i.e. selecting a Rails version >5.1.2 causes this to occur)
Click for "Rails Version" label the version that finished downloading from the drop-down (i.e. 5.0.0)
Enter "Working Directory" label value of "../"
Enter a "Module Name" (i.e. videotube-5.0.0)
Click "Apply" and "Save"
Go to Menu > Run > Edit Configurations
Change any directories that do not point to root folder of app
Go to Menu > Run > Debug
My variant to solve same problem.
Create new run configuration, but use "Ruby" template instead of "Redmine":
Ruby script field set to path to your redmine rails bin path and Script arguments set to "server -b 127.0.0.1 -p 3000 -e development" for ex.
This worked for me
Remove the .idea file
Invalidate the cache and restart the ide
Ok, this RubyMine has some serious issues. My day started out peaceful and then ended as a nightmare, courtesy of RubyMine. All I did was git checkout to a certain version of my repo. Well, when I did that, suddenly the folders in RubyMine disappeared. Yes, that is the first bug. I git checkout 8d4fbd1b5dfce0a3daa16896a603903a And then I open RubyMine and folders are gone! I closed and reopened. Still no folders. I restarted computer and still no folders.
I had to go to Project > File Structure and delete the Module. And then create a new Module. Now the project folders appear. But then I get this obscure error Rails server launcher wasn't found in the project. I have no idea what it means. I go online and they say delete .idea directory in your project. So I do that. And now again I have to delete and recreate the module.
This time it says "overwrite directory" since I have an existing project. I select "Yes" and then I open project and my secrets.yml is gone! Now I had to use secrets.yml I had backed up. And then finally it works.
Seriously, all this just because I wanted to checkout out a specific git commit? Come on.
UPDATE
After further investigation, I understand what is going on. There are three critical Intellij Idea files with regards to the Ruby plugin:
/.idea/
MyProject.iml
/MyProjectGemset/
These three files should not be checked into git and should be consistent across the different branches of your project. You might have another *.iml in the project. Delete that and make sure you are using the same .iml throughout the branches.
These two files pertain to your SDK:
MyProject.iml
/MyProjectGemset/
This file pertains to general configuration:
/.idea/
I've came across this same problem, and a way I found to solve it was to properly defining the root folder of the project when opening it in the first time with RubyMine.
As far as I can understand, ideally you should open the project by pointing the RubyMine to the project's root folder:
my-workplace/
|-- rails-project-name/ <-- point RubyMine here when openning
| |-- app/
| |-- bin/
| |-- config/
| |-- db/
| |-- lib/
| |-- log/
| |-- public/
| |-- test/
| ...
if you follow the solution from Artyom Blagoda on the Windows with ruby installed on the WSL (Ubuntu) you'll get into situation when wsl path (\wsl$\Ubuntu) of ruby script (rails) could not be found by remote (Ubuntu) ruby interpreter. to make it work you need to add path mapping on:
Settings -> Ruby SDK and Gems -> Your remote ruby or RVM -> then click the folder icon above, you'll find a new window where you put:
Local Path: //wsl$/Ubuntu/PATH_TO_YOUR_RAILS_BIN
Remote Path: PATH_TO_YOUR_RAILS_BIN
hope it helps ;)
I just installed ruby on rails on my new computer ( I was using instantrails before) and I'm trying to get everything setup.
Im running Windows 7. So I followed the instructions from this tutorial.
http://blogupstairs.com/ruby-on-rails/installing-ruby-on-rails-on-windows-7/
The problem i'm guessing is step 3
"Add the newly installed bin directory to your path in your windows system : Open windows explorer-> right click the icon computer-> choose Properties -> in the contol panel Home, Click Advanced system settings and then click Envitonment Variables button->in the system variables click new and add new system variables like this : Variable name : RUBY_HOME , Variable Value : C:\Ruby, after that add it in to the path and add the bin after a semicolon to the “Path” variable like this : C:\Program Files\Common Files\Adobe\AGL;%JAVA_HOME%\bin;%ANDROID_HOME%\tools;%RUBY_HOME%\bin"
I set created the system variables but when I try to run script/generate in the main directory of my app I get the error
"Ruby: no such file or directory --script/generate"
I checked the apps directory and the script folder is in there. How can I run the "ruby script/generate" commands from the control panel?
I was guessing it was something with the path but I dont know any ways to check to find out whats going wrong.
Are you using Rails 3.0+? In this version of rails and up, the script/* folder has been deprecated in favor of rails generate, rails server, etc. See here.
In 99.99999% of all cases, if a computer tells you that it cannot find a file at a specific location, it is because that file is not at that specific location.
So, is there actually a file named generate in a directory named script in the current directory?
I have recently installed RoR on my "clean" Win7 as well.
What IDE are you using?
I suggest trying JRuby with NetBeans/RubyMine:
JRuby installer does all the work (even adds the proper variables to your path in system environment settings...,
IDEs take care of gems, setting up servers etc.
As for the commands, as Nuclearsandwitch mentioned, there is no script/generate or script/server in Rails 3. Just make sure you in the directory with your Rails app and then try running rails server. It should work :-)
I installed Ruby and Ruby on Rails yesterday on Vista 32bit using the directions on this site: http://rubyonrails.org/down
So I downloaded the installer, then Gems, then I downloaded rails with Gems.
Now I can't use the Gem or Ruby commands in the command line... so I assume there's something wrong with the environment variables, but I hav eno idea how to set them up in Vista or what to put.
Can anyone help me with this?
To set up the environment variables, do this
Fire up the start menu
Right-Click on Computer and select Properties
Click Advanced system settings in the left-hand bar, and confirm the UAC prompt
Select the Advanced tab (it's 3rd)
Click Environment Variables... (at the bottom)
In the top box (User variables for XXX) either find the entry for PATH, or click new to create the entry.
If there is already a PATH use semi-colons to seperate each directory listed in it
Put c:\ruby\bin (change if you installed ruby somewhere else) in.
Click OK a lot of times to close all the windows we opened.
Restart your command prompt.
gem and ruby and irb should now all work. Whoever said that GUI tools are slower than command line tools. pshaw!
In the command line window type PATH then hit return, do you see ruby.exe on the PATH environment variable?
If you installed ruby to say c:\ruby then it'll be c:\ruby\bin\.
Looks like it may be missing from the path.
Add your ruby bin directory to your PATH environment variable, go to Control Panel -> System -> Advanced system settings, then go to the Advanced tab, Environment Variables, then edit your PATH variable and append the path to the ruby binaries install i.e. ;C:\ruby\bin