Ignoring 'ln' errors in Vagrant provisioning

2

I'm using a shell script in my Vagrantfile to create a symlink for Node.js (in a Ubuntu VM):

ln -s /usr/bin/nodejs /usr/bin/node

That works fine when I call vagrant up for the first time, but when I call vagrant up --provision after that (i.e., when the symlink already exists), I get the following error:

==> default: ln: 
==> default: failed to create symbolic link ‘/usr/bin/node’: File exists
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

How can I make Vagrant ignore the error raised by ln? I have already tried to redirect its output to /dev/null, but that results in the same error:

ln -s /usr/bin/nodejs /usr/bin/node 2>/dev/null || true

ChristianK

Posted 2014-11-15T21:12:15.057

Reputation: 125

Answers

2

You can use the -f parameter:

ln -s -f /usr/bin/nodejs /usr/bin/node

See ln - Linux Command.

Cornelius

Posted 2014-11-15T21:12:15.057

Reputation: 2 524