vagrant mount 上的 shebang 不起作用:错误的解释器:无效的参数

vagrant mount 上的 shebang 不起作用:错误的解释器:无效的参数

如果我尝试在 vagrant mount 内部而不是外部执行文件,我会遇到一个奇怪的问题:

$ cat test 
#!/usr/bin/env node

console.log('works!')

$ ls -la test 
-rwxr-xr-x 1 vagrant vagrant 43 May 13 23:17 test

$ ./test 
bash: ./test: /usr/bin/env: bad interpreter: Invalid argument

$ /usr/bin/env node test
works!

$ cp test /tmp/; cd /tmp/
$ ./test 
works!

一些细节:

$ cat /etc/fstab | grep workspace
home_vagrant_workspace /home/vagrant/workspace vboxsf uid=1000,gid=1000,_netdev 0 0

$ mount | grep workspace
home_vagrant_workspace on /home/vagrant/workspace type vboxsf (rw,nodev,relatime,iocharset=utf8,uid=1000,gid=1000,_netdev)

还尝试过:

$ cat /etc/fstab | grep workspace
home_vagrant_workspace /home/vagrant/workspace vboxsf defaults,dev,exec,uid=1000,gid=1000 0 0

$ mount | grep workspace
home_vagrant_workspace on /home/vagrant/workspace type vboxsf (rw,nodev,relatime,iocharset=utf8,uid=1000,gid=1000)

客人:

$ uname -a
Linux vagrant 5.11.0-11-generic #12-Ubuntu SMP Mon Mar 1 19:26:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=21.04
DISTRIB_CODENAME=hirsute
DISTRIB_DESCRIPTION="Ubuntu Hirsute Hippo (development branch)"

主机:MacOS BigSur 11.3 (20E232) 提供商:VirtualBox

流浪者片段:

    config.vm.box = properties["data"]["machine"]["box"] // bento/ubuntu-21.04
    # Shared Folders Configuration
    if (properties["data"].include? "shared_folders")
        properties["data"]["shared_folders"].each do |folder, index|
            config.vm.synced_folder folder["item"]["host"], folder["item"]["guest"], id: index, owner: "vagrant", group: "vagrant"
        end
    end

有什么建议如何处理吗?

答案1

内核中似乎存在更改,导致与 Parallels Tools 不兼容。Parallels 论坛上的相关主题。也许这与您在设置中遇到的错误具有相同的根本原因。

解决方法是不直接执行脚本文件(通过#!),而是直接调用解释器,例如bash foo.sh代替./foo.sh.

相关内容