{"_id":"54d0351994f7980d0081b848","__v":32,"category":{"_id":"54cfba19bba1a023008741b9","__v":24,"pages":["54d0351994f7980d0081b848","54d03542c795960d009f4219","54d0357d94f7980d0081b84b","54d039c3f530ca0d0005396a","54d039e394f7980d0081b859","54d03a1294f7980d0081b85b","54d03a3bf530ca0d0005396e","54d03a9294f7980d0081b85e","54d03abdc795960d009f4220","54d03ade94f7980d0081b860","54d03b02f530ca0d00053970","54d03b3794f7980d0081b862","54d03b69f530ca0d00053973","54d03b8994f7980d0081b864","54d03bb1c795960d009f4222","54d8f49e6a09052100a6b60e","54ec495d7ab3172d00c01a92","54ec6f2ec0c0ba1700386fa6","54f6f3f852174719008f6168","5628ed9b48742a0d00474591","564b714fcc472d0d00da941e","564b9e65288b1a2b00b3ae7d","564ba4872cabb82100943f0d","56995b3e54d7db17000ee9e6"],"project":"54cf411f9d09bb0d00a17a1c","version":"54cf411f9d09bb0d00a17a1f","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-02-02T17:55:37.930Z","from_sync":false,"order":4,"slug":"running-and-debugging","title":"Running and Debugging"},"project":"54cf411f9d09bb0d00a17a1c","parentDoc":null,"user":"54cfa8c8a8a4fd0d00b7fd1c","version":{"_id":"54cf411f9d09bb0d00a17a1f","project":"54cf411f9d09bb0d00a17a1c","__v":14,"createdAt":"2015-02-02T09:19:27.656Z","releaseDate":"2015-02-02T09:19:27.656Z","categories":["54cf41209d09bb0d00a17a20","54cfb99bbba1a023008741af","54cfb9a65ff7e617002bbd7f","54cfba03bba1a023008741b6","54cfba0ebba1a023008741b8","54cfba19bba1a023008741b9","54cfba29bba1a023008741bb","54cfba345ff7e617002bbd87","54cfba3ebba1a023008741bc","54cfba473995cf0d0006f6f0","54e371b18ef7552300409bf2","54e37aa5e887c50d005ef629","555a4e9b147f91190092d137","56b0e91802f4bc0d006ce254"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":["55655373148f9a0d00635cd0"],"next":{"pages":[],"description":""},"createdAt":"2015-02-03T02:40:25.578Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"Cloud9 IDE provides the ability to run and debug your code from within your workspace. This guide is mainly geared toward Javascript/Node.js applications but there are some specifics on [PHP here](https://c9.io/blog/debug-your-php-code-with-xdebug-and-cloud9/). Aside from debugging, you can also execute Javascript/Node.js, Python, Ruby, and Apache+PHP applications.\n\nThe following information applies to all of the above programming languages.\n\n# Running Code\n\nFirst, open the file you want to run. Usually, this file is going to be the main entry point to your app; for example, if you're creating a server, you'd want to run the file that actually instantiates that server.\n\nThere are two ways to run your code: either through the Run Panel, or through the **run** button in the menu bar.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Processes Automatically Stop\",\n  \"body\": \"After a workspace is left [inactive for a certain period of time](https://docs.c9.io/docs/inactive-workspaces), processes will stop and application previews will no longer work. If you try to access the application you'll see a message that says \\\"No application is running here\\\". When this happens just start your server over again or run the application again and you can preview your site once again.\"\n}\n[/block]\n## Using the Run Panel\n\nNext, click on the **Run** button in the top menu bar. You'll notice immediately that your active file is already available to run. Just double-click on the file, and you'll launch your app.\n\nWhen you're ready to stop your app, click on the Stop button in the menu bar at any time.\n\nAt the bottom of the run panel, you'll notice a few more options you can set. Filling these textboxes out creates a _run scenario_, which is like setting up some configurations for the way your code runs. These options are:\n\n* **Name** the name of your run scenario\n* **File Path**: the location of your running file in your project\n* **Runtime**: defines how you want your code to be run. Typically, you'd set different runtime versions here.\n* **Cmd Line Args**: allows you to provide any additional command line arguments you want to pass to your app\n\nOf course, you can also save your run scenarios; just click on the **add** button at the top of the panel. When you're ready to run a scenario, click on its name in the Run panel list. To remove a run scenario, click on its name in the run panel list, and then click on the **remove** button. \n\n## Using the Run Button\n\nThe **run** button in the menu bar acts as a sort of short cut to the Run panel. When clicked, the button automatically runs the currently active file. You may also right-click the button for a list of possible run options:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/f796LDPCSh2SxEAPJBHg_Screen%20Shot%202015-06-15%20at%2011.54.09%20AM.png\",\n        \"Screen Shot 2015-06-15 at 11.54.09 AM.png\",\n        \"348\",\n        \"170\",\n        \"#c2953f\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n## CWD\n\nThe CWD button gives you the option to change the [current working directory](http://www.cyberciti.biz/faq/howto-display-working-directory-name/). Depending on what runner you're using, the process usually runs in the directory your current file is in. If you change CWD, this will change the location from which the process is run.\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/X0BAlWXlQkGB7lvwbEfT_cwd.png\",\n        \"cwd.png\",\n        \"3186\",\n        \"174\",\n        \"#802c2c\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\nThe screenshot above mentions that CWD will override working_dir because this is a variable set in the runner itself. If you're interested in modifying or making your own runners, check out [Custom Runners](doc:custom-runners), otherwise just ignore this part ๐Ÿ˜‰\n\n## Console Output\n\nEvery time you run a project, the console expands to reveal output from your program. If you're launching a server, Cloud9 provides you with a URL to access the project. Otherwise, any statements sent by your application's print statements (like `console.log()` for Javascript, `print` for Python, or `puts` for Ruby) are also shown here. For example:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/1OZmBCbRnSQKiDhwL7sM_runOutput.png\",\n        \"runOutput.png\",\n        \"733\",\n        \"85\",\n        \"#759cae\",\n        \"\"\n      ]\n    }\n  ]\n}\n[/block]\n---\nFor information on how to debug your code, head to [Debugging Your Code](doc:debugging-your-code).\n\n## Related Sources:\n- [Writing a Go App](https://community.c9.io/t/writing-a-go-app/1725)\n- [Writing a Simple HTML Webpage](https://community.c9.io/t/writing-a-simple-html-page/1726)\n- [Writing a Node.js App](https://community.c9.io/t/writing-a-node-js-app/1731)\n- [Writing A Coffeescript App](https://community.c9.io/t/writing-a-coffeescript-app/1776)\n- [Getting Started with Angular.js](https://community.c9.io/t/getting-started-with-angularjs/1729)\n- [Getting Started with EmberJS](https://community.c9.io/t/getting-started-with-emberjs/1788)\n- [Getting Started with Express.js](https://community.c9.io/t/getting-started-with-express/1794)\n- [Writing A PHP App](https://community.c9.io/t/writing-a-php-app/1488)\n- [Writing a Python App](https://community.c9.io/t/writing-a-python-app/1609)\n- [Running a Python CGI Server](https://community.c9.io/t/running-a-python-cgi-server/1602)\n- [Writing a Ruby App](https://community.c9.io/t/writing-a-ruby-app/1613)\n- [Running a Rails App](https://community.c9.io/t/running-a-rails-app/1615)\n- [Creating a Scala App](https://community.c9.io/t/creating-a-scala-app/1605)","excerpt":"","slug":"running-and-debugging-code","type":"basic","title":"Running Your Code"}
Cloud9 IDE provides the ability to run and debug your code from within your workspace. This guide is mainly geared toward Javascript/Node.js applications but there are some specifics on [PHP here](https://c9.io/blog/debug-your-php-code-with-xdebug-and-cloud9/). Aside from debugging, you can also execute Javascript/Node.js, Python, Ruby, and Apache+PHP applications. The following information applies to all of the above programming languages. # Running Code First, open the file you want to run. Usually, this file is going to be the main entry point to your app; for example, if you're creating a server, you'd want to run the file that actually instantiates that server. There are two ways to run your code: either through the Run Panel, or through the **run** button in the menu bar. [block:callout] { "type": "info", "title": "Processes Automatically Stop", "body": "After a workspace is left [inactive for a certain period of time](https://docs.c9.io/docs/inactive-workspaces), processes will stop and application previews will no longer work. If you try to access the application you'll see a message that says \"No application is running here\". When this happens just start your server over again or run the application again and you can preview your site once again." } [/block] ## Using the Run Panel Next, click on the **Run** button in the top menu bar. You'll notice immediately that your active file is already available to run. Just double-click on the file, and you'll launch your app. When you're ready to stop your app, click on the Stop button in the menu bar at any time. At the bottom of the run panel, you'll notice a few more options you can set. Filling these textboxes out creates a _run scenario_, which is like setting up some configurations for the way your code runs. These options are: * **Name** the name of your run scenario * **File Path**: the location of your running file in your project * **Runtime**: defines how you want your code to be run. Typically, you'd set different runtime versions here. * **Cmd Line Args**: allows you to provide any additional command line arguments you want to pass to your app Of course, you can also save your run scenarios; just click on the **add** button at the top of the panel. When you're ready to run a scenario, click on its name in the Run panel list. To remove a run scenario, click on its name in the run panel list, and then click on the **remove** button. ## Using the Run Button The **run** button in the menu bar acts as a sort of short cut to the Run panel. When clicked, the button automatically runs the currently active file. You may also right-click the button for a list of possible run options: [block:image] { "images": [ { "image": [ "https://files.readme.io/f796LDPCSh2SxEAPJBHg_Screen%20Shot%202015-06-15%20at%2011.54.09%20AM.png", "Screen Shot 2015-06-15 at 11.54.09 AM.png", "348", "170", "#c2953f", "" ] } ] } [/block] ## CWD The CWD button gives you the option to change the [current working directory](http://www.cyberciti.biz/faq/howto-display-working-directory-name/). Depending on what runner you're using, the process usually runs in the directory your current file is in. If you change CWD, this will change the location from which the process is run. [block:image] { "images": [ { "image": [ "https://files.readme.io/X0BAlWXlQkGB7lvwbEfT_cwd.png", "cwd.png", "3186", "174", "#802c2c", "" ] } ] } [/block] The screenshot above mentions that CWD will override working_dir because this is a variable set in the runner itself. If you're interested in modifying or making your own runners, check out [Custom Runners](doc:custom-runners), otherwise just ignore this part ๐Ÿ˜‰ ## Console Output Every time you run a project, the console expands to reveal output from your program. If you're launching a server, Cloud9 provides you with a URL to access the project. Otherwise, any statements sent by your application's print statements (like `console.log()` for Javascript, `print` for Python, or `puts` for Ruby) are also shown here. For example: [block:image] { "images": [ { "image": [ "https://files.readme.io/1OZmBCbRnSQKiDhwL7sM_runOutput.png", "runOutput.png", "733", "85", "#759cae", "" ] } ] } [/block] --- For information on how to debug your code, head to [Debugging Your Code](doc:debugging-your-code). ## Related Sources: - [Writing a Go App](https://community.c9.io/t/writing-a-go-app/1725) - [Writing a Simple HTML Webpage](https://community.c9.io/t/writing-a-simple-html-page/1726) - [Writing a Node.js App](https://community.c9.io/t/writing-a-node-js-app/1731) - [Writing A Coffeescript App](https://community.c9.io/t/writing-a-coffeescript-app/1776) - [Getting Started with Angular.js](https://community.c9.io/t/getting-started-with-angularjs/1729) - [Getting Started with EmberJS](https://community.c9.io/t/getting-started-with-emberjs/1788) - [Getting Started with Express.js](https://community.c9.io/t/getting-started-with-express/1794) - [Writing A PHP App](https://community.c9.io/t/writing-a-php-app/1488) - [Writing a Python App](https://community.c9.io/t/writing-a-python-app/1609) - [Running a Python CGI Server](https://community.c9.io/t/running-a-python-cgi-server/1602) - [Writing a Ruby App](https://community.c9.io/t/writing-a-ruby-app/1613) - [Running a Rails App](https://community.c9.io/t/running-a-rails-app/1615) - [Creating a Scala App](https://community.c9.io/t/creating-a-scala-app/1605)