facebook / hhvm

A virtual machine for executing programs written in Hack.
https://hhvm.com
Other
18.13k stars 2.98k forks source link

hh_client/hh_server do not follow symlinks #2160

Open sebastianbergmann opened 10 years ago

sebastianbergmann commented 10 years ago
$ ls -lha
total 4.0K
drwxr-xr-x.  2 sb   sb    80 Mar 24 07:26 .
drwxrwxrwt. 14 root root 480 Mar 24 07:26 ..
-rw-r--r--.  1 sb   sb     0 Mar 24 07:18 .hhconfig
-rw-r--r--.  1 sb   sb    91 Mar 24 07:26 test.php

$ cat test.php
<?hh //strict
class foo {
 public function bar(array $baz) {
  if (isset($baz)) {
  }
 }
}

$ hh_client 
/tmp/project/test.php:4:7,11: Unbound name: isset

$ ln -s /usr/local/src/hhvm/hphp/hack/hhi .
$ hh_client 
/tmp/project/test.php:4:7,11: Unbound name: isset

$ rm -rf hhi
$ cp -r /usr/local/src/hhvm/hphp/hack/hhi .
$ hh_client 
/tmp/project/test.php:3:22,26: You cannot have an array without generics in strict mode
jwatzman commented 10 years ago

It looks like we follow symlinked files but not directories. Interesting. I'll take a look.

jwatzman commented 10 years ago

In the meantime, you can copy them in as the docs suggest -- but I agree that this should work.

jwatzman commented 10 years ago

Chatted with our tech lead about this. It turns out that it's surprisingly difficult to deal with incremental mode (i.e., watching files via inotify) when following directory symlinks. We agree that we need to deal with this somehow, but it's not clear what the right solution is. We'll think about it and get back to this -- unfortunately probably in a few weeks since we're busy prepping for the Hack developer day.

sdwilsh commented 8 years ago

@jwatzman - is this a limitation of watchman?

jwatzman commented 8 years ago

@sdwilsh When this issue was opened, hh_server wasn't using watchman, it was using its own home-grown solution, which had this limitation. I think it might use watchman nowadays, or maybe can optionally, so I'm not sure what the modern state of this issue is. (I also have no idea if watchman has the same limitation.)

Orvid commented 8 years ago

I believe hh_server uses inotify now doesn't it?

abirchall commented 5 years ago

any update on this?

fredemmott commented 5 years ago

We still use OS-native file watching unless watchman is explicitly configured, and currently do not follow symlinks (although there are also some issues with incremental mode)

Depending on your use case, extra_paths=../foo/bar,../baz in .hhconfig might be a usable workaround