如何在Cloud9 IDE中使用Ruby语言运行Processing?
Hey there! Let's work through getting Ruby-Processing up and running in your Cloud9 environment—since you're new to this, I'll break every step down clearly to avoid confusion.
First: Understand Your Core Mistakes
You tried setting PROCESSING_ROOT to a Mac-specific path (/Applications/Processing.app/Contents/Java), but Cloud9 runs on a Linux-based cloud environment—this path doesn't exist here. Plus, you used the wrong syntax to set the variable directly in bash, and likely misnamed the config file (it's .rp5rc, not .rpsrc), which caused the uninitialized constant error.
Step 1: Install Processing in Cloud9
First, you need to actually install Processing on your Cloud9 workspace—you can't point to a local Mac path here. Run these commands in your terminal:
# Download the latest Linux 64-bit Processing version (adjust URL if a newer release exists) wget https://github.com/processing/processing4/releases/download/processing-4.3/processing-4.3-linux-x64.tgz # Extract the downloaded archive tar -xzf processing-4.3-linux-x64.tgz # Optional: Rename the folder to something shorter/easier to reference mv processing-4.3 processing
This will install Processing in your home directory (~/processing).
Step 2: Create the Correct Config File
Ruby-Processing looks for a file named .rp5rc in your home folder to load its configuration. Let's create and edit it:
# Open the file with nano (a simple terminal text editor) nano ~/.rp5rc
Paste this line into the file, making sure the path matches where you extracted Processing:
PROCESSING_ROOT="/home/ubuntu/processing"
Save and exit nano by pressing Ctrl+O, hitting Enter, then Ctrl+X.
Step 3: Verify Your JRuby & Ruby-Processing Setup
Make sure JRuby is your active Ruby version (and set it as default to avoid redoing this later):
rvm use jruby --default
Then run the Ruby-Processing check command to confirm your config is recognized:
rp5 check
If this outputs your PROCESSING_ROOT path without warnings, you're good to go.
Step 4: Test with a Simple Sketch
Create a file named Draw.rb with this basic code:
require 'ruby-processing' class MySketch < Processing::App def setup size(200, 200) background(255) end def draw fill(0, 150) ellipse(mouse_x, mouse_y, 50, 50) end end MySketch.new
Run it with:
rp5 run Draw.rb
Since Cloud9 is a cloud environment, access the Processing GUI via Cloud9's preview feature:
- The sketch starts on port 8080 by default.
- Click the "Preview" button in your Cloud9 toolbar, then select "Preview Running Application" to see your sketch.
Troubleshooting If Errors Persist
- Double-check the path in
.rp5rc: Runls ~/processingto confirm the folder exists. Update the path if you renamed the folder differently. - Confirm the config file name: It must be
.rp5rc(not.rpsrcor any other variation). - Reinstall ruby-processing if needed: Run
gem uninstall ruby-processingthengem install ruby-processingwhile using JRuby.
内容的提问来源于stack exchange,提问作者Waterman33




