Hgfs shared filesystem in VMWare does not support symlinks

bundle exec rake db:migrate db:test:prepare db:seed_fu fails:

ln: failed to create symbolic link 'public/plugins/discourse-narrative-bot': Permission denied
lib/discourse.rb:28:in `execute_command'
lib/plugin/instance.rb:459:in `activate!'
lib/discourse.rb:147:in `block in activate_plugins!'
lib/discourse.rb:144:in `each'
lib/discourse.rb:144:in `activate_plugins!'
config/application.rb:186:in `<class:Application>'
config/application.rb:26:in `<module:Discourse>'
config/application.rb:25:in `<top (required)>'
rakefile:5:in `require'
rakefile:5:in `<top (required)>'
~/.rbenv/versions/2.4.2/bin/bundle:23:in `load'
~/.rbenv/versions/2.4.2/bin/bundle:23:in `<main>'

It looks like this issue has not been solved for many years: communities.vmware.com/thread/312591

I ended up moving the directory out of my VM’s shared folder to a new location.
It seems to be installing fine now.
I don’t guess the symlink works when its in a shared folder.

stackoverflow.com/questions/40920896#comment69054665_40920896

Symbolic links seem to be a recurrent problem for VMWare shared directories between different operating systems.

github.com/Cisco-Talos/pyrebox/issues/12#issuecomment-320589824

Currently for Windows hosts symlinks are not supported.
We currently don’t have plans to add it either.

sourceforge.net/p/open-vm-tools/mailman/message/29280098

The underlying file system in Windows is NTFS which does not support symbolic links in the same way as Linux does.
The creation of symlinks in directories that are NTFS mounts (like the vagrant shared folders) will always fail.

github.com/hashicorp/vagrant/issues/5840#issuecomment-115051381

So, how to use VMware Workstation as a development environment for Discourse with Windows host operating system?
Maybe there is a workaround?

What instructions are you following? I don’t recall having ever seen any that involved going into /mnt /hgfs/code

I need to make the Discourse’s folder shared between my Windows host and my VMware Workstation Ubuntu guest to use an integrated development environment (IDE) of my host operating system.

My workaround is to patch the Plugin::Instance.activate! method.

Locate the code:

https://github.com/discourse/discourse/blob/v1.9.0.beta17/lib/plugin/instance.rb#L458-L459

Replace it with the code:

Discourse::Utils.execute_command('rm', '-rf', target)
begin
  Discourse::Utils.execute_command('ln', '-s', public_data, target)
rescue
  Discourse::Utils.execute_command('cp', '-r', public_data, target)
end

I use VMWare, strongly recommend against putting the code in the fused filesystem it will be much slower. I keep it on my ext3 volume inside the vm.

If really really want windows to have access to this stuff for IDE

Option 1:

Set up samba locally and just edit off samba

Option 2:

Use something like http://docker-sync.io/

6 Likes

What do you think about including my solution above to the code?

It breaks the way plugins install, not ideal.

3 Likes