How do I create a Rails run configuration on Aptana Studio 3? - ruby-on-rails

I'm using Aptana Studio 3 on Mac OS X (High Sierra). I have imported my Ruby on Rails project. My Project Natures are set up like this
I want to set up my Rails server so I can run it from the IDE (or debug with it). Oddly, the Run/Debug settings only include PHP ...
So how do I create a run configruation to run my server? When I right click my project, select "Run As" -> "Run Configurations", I see a screen like this. Not sure if this is the right screen to configure things or how to do it ...

You can run your server creating a run configuration or just creating a new Rails Server.
Creating a Run Configuration
In "Run Configurations" options, select Ruby Applications > New_configuration and then click in "Browse...". Type 'rails' to search for the rails file and select it inside "Matching resources". Click "Ok".
Then go to Tab "Arguments", set the working directory as the root folder of your project, and inside "Program Arguments" put the value "server" and click "Apply".
Now you can run or debug your application.
Creating a Rails Server
Go to Windows > Preferences > Aptana Studio > Web Servers and click in "New...".
Then select the option "Rails Server", choose the name of your server and click "Ok". If your project nature was not set to "Rails" the option "Project" would be empty here, and you would need to set the Rails nature first.
If you try to run the server like this you will receive an error telling that the program ".../script/rails" does not exist, so first you need to create a folder named "script" inside your project and paste the file "bin/rails" inside it (as explained here).
Now just click with the Right mouse button in your project and select "Run server".

Related

Debug a Grails 3.x application

I am trying to debug a Grails 3.x application using grails run-app --debug-fork. But when the application starts it does not wait for the debugger to attach. Any solution on how to debug a Grails 3.x application?
Please use the --debug-jvm flag.
For example: grails --debug-jvm run-app
In IntelliJ you can right click the Gradle task bootRun and select Debug.
The other option is to directly run the Application class located in grails-app/init. It has a static void main and be run as a regular application. You can run it directly from your IDE with a debug profile.
In IntelliJ IDEA 2016.1, I create two configurations. This allows me to make solid use of all the context menus, etc. that IntelliJ IDEA offers. Here's how:
The first configuration is a "Run" configuration. Edit the default
configuration and in the "Command Line" field, enter
run-app --debug-jvm
The second configuration is a "Remote" configuration. On the "Run/Debug" dialog, click the + symbol and select "Remote" from the
list. Name it "Debug" and save.
Select your "Run" config from the config dropdown at the top and then click the green arrow to run the app. Monitor the console
output until you see the message
Listening for transport dt_socket at address: 5005.
Select the remote debug profile you created in step 2 and click the debug button. In a few moments the console output will say
Grails application running at http://localhost:8080 in environment: development.
Success!

RubyMine: Rails server launcher wasn't found in the project

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 ;)

Virtual ruby - No such file or directory -- main.rb (LoadError)

I have installed visual ruby in windows7. It got installed properly. But
when i start the application, 'visual ruby project root' opens but no
folders are displayed there, so i chose select folder and selected a
example project and clicked open. Now the visual ruby application got
opened and the list of example projects got displayed in the left pan.
If i select any of the project and click run am getting the following
error.
C:/Users/abhiram/visualruby/examples$ ruby main.rb
ruby: No such file or directory -- main.rb (LoadError)
I dono how to fix it. Could any one help me out of this.
Look in the menus for "Project Settings." There is a command line that shows the program that will run when you press the "run" button. The default is "ruby main.rb" It will simply execute that command when the "run" button is pressed. http://visualruby.net

"rails" command on windows

So I installed Ruby On Rails using the Windows Installer.
Now the startup guides says I have to start up an Terminal and run the Rails command to make a project. I don't have a terminal, so how do I execute a Rails command and make a project??
The CMD command line in Windows does not recognize "rails"
I don't think it is an PATH problem, because when I'm in the "Bin" directory, there is "rails.bat" and "rails" with no extension. If I run Rails.bat I get "The filename, directory name, or volume label syntax is incorrect."
I get that message with whatever Argument I pass to it.
It seems to be a bug in the rails.bat file because of double-quotes, like:
#"ruby.exe"" "%~dpn0" %*
Remove the double quotes:
http://sepitfalls.blogspot.com/2008/12/updateing-rubygems-broke-gem-command.html
To get a terminal
Start > Run... or Windows key + R
Type "cmd" and hit enter.
To add a folder to the command line's path
On Windows XP (Vista is similar)
Start > Control Panel > System
Click the "Advanced" tab
Click "Environmental Variables"
Under "System Variables" double click on Path and edit accordingly.
You will need to open a new command line in order to get the updated path to take affect. With XP, I've had to reboot to force it to take affect but it shouldn't be necessary.
The Path variable is a semi-colon seperated list of folders in which the Command Line or "terminal" looks for commands.
You'll probably have to find the rails command yourself. I would try looking for a rails.bat or rails.cmd file.
I think they mean the command window. Try running it from a command line.
I dont know where the Windows Ruby on Rails intaller places its files, but the ultimately solution is that you need to make sure that the "rails" command is is your PATH - which you can view/modify by right-clicking My Computer, selecting Properties, going to the Advanced tab and then clicking on "Environment Variables" and then scrolling down until you see "PATH" and adjusting it accordingly. You probably need to find the directory where the "rails" command lives and append to the end of the existing PATH entry, inserting a ";" before you enter the new path to append it to the existing PATH.
So find where "rails" is and add its directory to your PATH.
You probably have to change your PATH in Windows to point to wherever the rails executable has been installed.
The PATH environment variable is used to determine where Windows looks for stuff; when you type, for instance, 'calc' Windows will hunt through its PATH and eventually find and run C:\Windows\calc.exe. In your case, the PATH doesn't include the directory you need, so Windows isn't searching in that directory for rails.exe when you type "rails."
To fix this, right click on "My Computer" -> "Properties" -> "Advanced" -> "Environment Variables" and then modify the PATH one to include the directory your rails.exe is in.
I recommend using cygwin for Rails development on windows - far too much of the community is using *nix. If you install the development tools package you'll automatically have svn, git and other doo-dads that you'll eventually need relating to various rails plugin installation. If you want to deploy using capistrano the installation is identical to all the instructions you find. Plus other tips and tricks people will reference will work exactly the same for you as it does for them, whereas some things are different for native windows and all the accessory tools have to be installed separately.

Cannot use gem and ruby command after install on Vista

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

Resources