I cannot get my first app academy practice program to run


#1

Write a method that will take a string as input, and return a new

string with the same letters in reverse order.

Don’t use String’s reverse method; that would be too simple.

Difficulty: easy.

def reverse(string)
reversed_string = “”

i = 0
while i < string.length
reversed_string = string[i] + reversed_string

i += 1
end

return reversed_string
end

These are tests to check that your code is working. After writing

your solution, they should all print true.

puts(
'reverse(“abc”) == “cba”: ’ + (reverse(“abc”) == “cba”).to_s
)
puts(
'reverse(“a”) == “a”: ’ + (reverse(“a”) == “a”).to_s
)
puts(
'reverse("") == “”: ’ + (reverse("") == “”).to_s
)

The error message is

Your code is running at https://tryagain-joboggi.c9users.io.
Important: use ENV[PORT] as the port and ENV[IP] as the host in your scripts!

ruby: No such file or directory – /home/ubuntu/workspace/run (LoadError)

Process exited with code: 1

I have no idea what ENV[port] and ENV[IP and no such file and code 1 are. I did save the program. I am not sure why it says there is no file.

Thanks in advance for your help.


#2

ENV[PORT] and ENV[IP] are environment variables that c9 sets with the correct IP and port to run your app on. That usually isn’t fatal though, I think the problem is the ruby: No such file or directory -- /home/ubuntu/workspace/run (LoadError) error, where it’s trying to run your app but can’t find the file to run. Code 1 is an exit status code that basically just says “Error, we exited”. I’m not familiar with ruby, but I’m guessing that you have to put your code in /home/ubuntu/workspace/run to be able to run it, and after you resolve that, it will no longer throw an error and will run.