Ruby无法找到puts和其他命令?

Ton*_*ony 1 ruby macos

我试图做我认为应该是一个非常基本的脚本作为我的第一个ruby代码.也许有人可以帮我解决发生的事情.

./delete_file.rb: line 3: puts: command not found
./delete_file.rb: line 4: auth_token: command not found
./delete_file.rb: line 6: puts: command not found

User1$ cat delete_file.rb 
# /usr/bin/ruby
# Delete file script
puts "Enter current token"
auth_token = gets.chomp

puts "data goes here" + auth_token + "more data here"
Run Code Online (Sandbox Code Playgroud)

小智 7

第一行文件应该是:

#!/usr/bin/ruby
Run Code Online (Sandbox Code Playgroud)

  • 没有shebang,它会尝试将其作为bash文件执行. (2认同)