no imports can be found with watchman
When ever I install watchman no imports are found. As soon as I uninstall it the imports are found again.
This works for small projects but not for some of the bigger ones. I simply installed watchman, as far as I can tell there is no further configuration required by import-js.
Interesting. Could you
- change the
logLevelto"debug"in your config - clear the cache by running
rm $(importjs cachepath)from your project's root folder (you might have tonpm install -g importjsbefore this since the atom extension has the lib bundled). - then restart atom (or the extension itself, not sure how that works though).
- look at the logfile
cat $(importjs logpath)
@trotzig so, the log file from importjs logpath does not exist, but I get an error in the atom error console.
Watchman: watchman --no-pretty get-sockname returned with exit code=1, signal=null, stderr= [31mERROR[0m: Unknown option --no-pretty
after this error import-js falls back to resolve the import without watchman, this didn't happen before, but I can't tell what changed.
I think the "fallback" behavior you're seeing is because the cache has been filled once (without watchman). I bet it stays stale though, if you add more modules they won't show up when importing.
What version of watchman are you using? An upgrade might help, as suggested by this related thread.
yes, you are right, I now installed the latest version.
Importjs log file still doesn't exist:
cat: /var/folders/cj/3v9zc0z95s9gz2865w28qs180000gn/T/importjs.log: No such file or directory
I now don't get any errors in atoms console and the behavior is as before.
I think the "fallback" behavior you're seeing is because the cache has been filled once (without watchman). I deleted all cache DBs but after the fallback behavior occurred a new DB is created.
Also, I think it's definitely some kind of fallback because after the lookup with watchman failed, my breakpoint in the fb-watchman node module is not hit anymore.
Hrm, that's annoying.
The cache file being recreated is by design. import-js will try to recreate this file as soon as it can (whenever you try importing something).
I'm a little bit surprised that the log file isn't there. I wonder if atom is somehow overriding the default tmp folder for the system? Though it should be right there next to the cache files. If I remember correctly, even if you use the default log level it will post a few lines on startup.
when I run importjs fix <file path> I get a result back. But importjs cachepath gives me this path
/var/folders/cj/3v9zc0z95s9gz2865w28qs180000gn/T/import-js-215cee2763d25a940fc5194c3fdd142f.db
while the actual db is at:
/var/folders/cj/3v9zc0z95s9gz2865w28qs180000gn/T/import-js-683f13e9b2c620cffc97cf16e2004f76.db
there is still no log file.
The cache location difference might be a version mismatch thing. What does importjs --version tell you?
importjs --version
2.7.0
That's the latest, and assuming atom is configured to auto-update you should be on the same version through the extension (import-js is bundled with the atom extension).
Are you running the importjs fix command on the same file? The cache file will be unique to any project root (defined as a place where there is a package.json file).
yes I'm up to date with atom-import-js and yes I ran importjs fix on the same file, same package.json.
@trotzig importjs also is broken on some projects for me. I don't know why it suddenly broke.
Also be careful: npm install -g importjs does not install this imports, but another one: https://www.npmjs.com/package/importjs
the right name is: npm install -g import-js. Pretty confusing ;-)
@macrozone yes I made the same mistake before