ruby-on-railscloud9-idecloud9c9.io

Cloud9 Code 127, cannot run server, preview works


I cannot seem to get my server running via run button but the preview works and command works.

Steps I did to get to this point:

Started a blank cloud 9 instance and ran the following commands:

$ mkdir myapp

$ cd myapp

$ rvm use ruby-2.3.0@myapp --ruby-version --create

$ gem install rails

$ rails new .

$ rake -T

$ rails server -p $PORT -b $IP

At this point the preview works and I can access https://[workspace]-[user].c9users.io. However, if I press run then click CWD and select the myapp folder I get the following error:

myapp/Gemfile: No such file or directory

The command that shows up in the run panel is myapp/Gemfile I've also tried to use Gemfiel when changing CWD to the myapp folder and the myapp/Gemfile prior to changing cwd.

Is the run button just a way of running the command rails server -p $PORT -b $IP if so then as long as that command works and I can access the site, then there's no purpose to pressing run other than to save typing?


Solution

  • The first you need to consider, is that your app is running without problems (run rails s -p $PORT -b $IP without problems). If that is the case, is really simple to set your Run to run your app.

    First in your menu go to Run > Run Configuration > Run new configuration

    enter image description here

    Then It will open a run configuration tab, where you need to set your "Currente Working Directory" by clicking on CWD

    enter image description here

    And finally, you need to type your command (in the command textbox) to start your rails app, something like:

    rails s -p $PORT -b $IP
    

    With that you will get your app running with the Run button.

    Source: docs.c9