Skip to content

Commit 8ffa20c

Browse files
evanlucasjasnell
authored andcommitted
tools: do not rewrite npm shebang in install.py
Rewriting npm shebang in install.py violates user expectations among other things. The shebang in npm.js is kept as #!/usr/bin/env node. Fixes: #6095 PR-URL: #6098 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
1 parent 1384de2 commit 8ffa20c

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

tools/install.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,6 @@ def try_remove(path, dst):
7979
def install(paths, dst): map(lambda path: try_copy(path, dst), paths)
8080
def uninstall(paths, dst): map(lambda path: try_remove(path, dst), paths)
8181

82-
def update_shebang(path, shebang):
83-
print 'updating shebang of %s to %s' % (path, shebang)
84-
s = open(path, 'r').read()
85-
s = re.sub(r'#!.*\n', '#!' + shebang + '\n', s)
86-
open(path, 'w').write(s)
87-
8882
def npm_files(action):
8983
target_path = 'lib/node_modules/npm/'
9084

@@ -105,16 +99,6 @@ def npm_files(action):
10599
action([link_path], 'bin/npm')
106100
elif action == install:
107101
try_symlink('../lib/node_modules/npm/bin/npm-cli.js', link_path)
108-
if os.environ.get('PORTABLE'):
109-
# This crazy hack is necessary to make the shebang execute the copy
110-
# of node relative to the same directory as the npm script. The precompiled
111-
# binary tarballs use a prefix of "/" which gets translated to "/bin/node"
112-
# in the regular shebang modifying logic, which is incorrect since the
113-
# precompiled bundle should be able to be extracted anywhere and "just work"
114-
shebang = '/bin/sh\n// 2>/dev/null; exec "`dirname "$0"`/node" "$0" "$@"'
115-
else:
116-
shebang = os.path.join(node_prefix or '/', 'bin/node')
117-
update_shebang(link_path, shebang)
118102
else:
119103
assert(0) # unhandled action type
120104

0 commit comments

Comments
 (0)