PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, May 15, 2022

[FIXED] When I type Anything in Ubuntu it returns /usr/bin/env: ‘bash\r’: No such file or directory

 May 15, 2022     bash, reactjs, ubuntu     No comments   

Issue

When I type Anything in Ubuntu it returns /usr/bin/env: ‘bash\r’: No such file or directory

I noticed the issues when I tried making a react app

npx create-react-app app_name

it returns /usr/bin/env: ‘bash\r’: No such file or directory

Then when tried to check the versions of npm or anything else

it returns /usr/bin/env: ‘bash\r’: No such file or directory

The only thing that has worked so far is navigating through directories and making new ones.

I don't know what to do. please help


Solution

You have created an executable shell script with a shebang line #!/usr/bin/env bash. But you have likely created it on Microsoft Windows, and the line endings are \r\n (i.e. CRLF), instead of \n (LF) on Linux.

This does not work with shell scripts: you have to change the line endings to \n (Notepad++ can do that, for instance). What happens is, Linux reads lines separated by \n, so the first line ends with bash\r, and this is not the name of a known executable.

Note: this will fail not only with bash, but any script using a shebang: that can be Perl, Python, R, etc. That's because whatever the programming language, the executable is not called, because it's not found.

Note also that those programming languages usually read happily files with \r\n line endings. It's really the shebang line (i.e. executable scripts) that causes this problem.



Answered By - Jean-Claude Arbaut
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing