0

I followed this article to install & update ruby with a package manager but I clearly messed up somewhere.

https://stackify.com/install-ruby-on-your-mac-everything-you-need-to-get-going/

If I try to 'puts' or 'print' anything I get -bash: print: command not found / -bash: puts: command not found returned.

'ls' & 'cd' commands still work for example, but echo $path returns nothing.

As you have probably guessed, I am completely new to code & stupidly copy pasted lines into the shell that I don't understand.

Is this a path issue?

  • lp works in place of print. i'm not sure what puts is supposed to do. – jmh Dec 6 '19 at 17:00
  • puts shows up on a man page but it doesn't work for me either. When I do "which puts" it returns nothing. looks like it's been removed from macs. what are you trying to do. – jmh Dec 6 '19 at 17:09
  • puts, in this context, is a ruby function call. The link you posted is asking you to use vim to write the corresponding ruby command into a .rb (ruby) file, then running that in the ruby interpreter. This is not something type into a shell directly. – vykor Dec 7 '19 at 4:30
  • @vykor make it an answer :-) – ankii Dec 7 '19 at 7:57
1
  • print is not a standard bash command. I think so because man print returns no manual entry.

  • puts is a Standard C Library function and should be used inside a file and used as:

    #include <stdio.h>
    puts(const char *s);
    

    The function puts() writes the string s, and a terminating newline character, to the stream stdout.

    An example:

/* puts example : hello world! */
#include <stdio.h>

int main ()
{
  char string [] = "Hello world!";
  puts (string);
}

http://www.cplusplus.com/reference/cstdio/puts/

  • echo $path returns an empty line. It is case-sensitive. Use echo $PATH.

  • You need to save the ruby script in a file with appropriate file extension: .rb. Open Terminal, go the directory where the file is located using cd path/to/directory and run ruby filename.rb to see the results.

  • How to indent code block in markdown ? – ankii Dec 6 '19 at 17:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .