Comments (12)
I just verified I've got no issue using lint-staged
on the repo when connected to nas-server
via ssh.
from lint-staged.
Hey,
so the expected path is M:\Misc\temp repro\.git
but lint-staged finds M:\nas-server\nas\Misc\temp repro\.git
?
If you don't mind adding some console.log
or similar debugging for yourself, I believe the error happens somewhere around here:
lint-staged/lib/resolveGitRepo.js
Lines 12 to 25 in 26eee9d
Maybe it's line 24 where it essentially resolves the config path from "git dir"; could it be a relative path and gets messed up?
lint-staged/lib/resolveGitRepo.js
Line 24 in 26eee9d
from lint-staged.
Thanks for pointing me to the relevant function. I went ahead and added some logging to try to see what was happening.
new logs
M:\Misc\temp repro>npx lint-staged -d true
lint-staged:bin Running `[email protected]` on Node.js v18.16.0 (win32) +0ms
lint-staged:bin Options parsed from command-line: {
allowEmpty: false,
concurrent: true,
configPath: undefined,
cwd: undefined,
debug: true,
diff: undefined,
diffFilter: undefined,
maxArgLength: undefined,
quiet: false,
relative: false,
shell: false,
stash: true,
verbose: false
} +1ms
lint-staged:validateOptions Validating options... +0ms
lint-staged:validateOptions Validated options! +0ms
lint-staged Unset GIT_LITERAL_PATHSPECS (was `undefined`) +0ms
lint-staged:runAll Running all linter scripts... +0ms
lint-staged:runAll Using working directory `M:\Misc\temp repro` +0ms
lint-staged:resolveGitRepo Resolving git repo from `M:\Misc\temp repro` +0ms
lint-staged:resolveGitRepo Unset GIT_DIR (was `undefined`) +0ms
lint-staged:resolveGitRepo Unset GIT_WORK_TREE (was `undefined`) +1ms
lint-staged:execGit Running git command [ 'rev-parse', '--show-prefix' ] +0ms
lint-staged:resolveGitRepo resolveGitConfigDir | gitDir: `M:/Misc/temp repro` +134ms
lint-staged:resolveGitRepo resolveGitConfigDir | defaultDir: `/nas-server/nas/Misc/temp repro/.git` +2ms
lint-staged:resolveGitRepo Failed to resolve git repo with error: [Error: ENOENT: no such file or directory, lstat 'M:\nas-server\nas\Misc\temp repro\.git'] {
errno: -4058,
code: 'ENOENT',
syscall: 'lstat',
path: 'M:\\nas-server\\nas\\Misc\\temp repro\\.git'
} +2ms
✖ Current directory is not a git directory!
It looks like the exception is thrown by the lstat
call on line 19. The path being passed in is /nas-server/nas/Misc/temp repro/.git
which seems to be interpreted by lstat
as a path on the M drive.
After messing around in the node repl, I learned that fs.realpath
takes the path I'd expect to see (M:\Misc\temp repro\.git
) and transforms it into another path that works: \\nas-server\nas\Misc\temp repro\.git
Then normalizePath
takes that path and transforms it to /nas-server/nas/Misc/temp repro/.git
which doesn't work. I confirmed that removing the normalizePath
call on line 18 prevents the crash I was experiencing. However, the result of resolveGitConfigDir
is still being passed through normalizePath
and resolving to something that doesn't work so it crashes later on.
from lint-staged.
Hey, the normalizePath
is implemented in this repo along with an unit test file that seemingly already handles this (test/unit/normalizePath.spec.js
). Maybe there's some bug in the implementation or its usage.
Would M:/nas-server/nas/Misc/temp repro/.git
be a working path?
from lint-staged.
Would
M:/nas-server/nas/Misc/temp repro/.git
be a working path?
That's the path that doesn't work since there's no nas-server
folder on M:
. The correct path is M:/Misc/temp repro/.git
(but \\nas-server\nas\Misc\temp repro\.git
is the equivalent UNC path).
It doesn't seem like the tests are setup to handle a "standard" UNC path. Perhaps one with the \\?\
or \\.\
syntax (although I just learned those exist) is tested fine, but the relevant test for the path I get from fs.realpath
would have to look something like ['\\\\Server01\\user\\docs\\Letter.txt', '//Server01/user/docs/Letter.txt']
.
from lint-staged.
Just to be sure, what is the literal content of the .git
file in the repo? I assume it's roughly:
gitdir: M:/Misc/temp repro/.git
from lint-staged.
The root of the repo is M:/Misc/temp repro
and M:/Misc/temp repro/.git
is not a file, it's a folder. Are you asking about a file in that folder?
from lint-staged.
Hmm, maybe I was misunderstanding this issue. I assume your git repo directory was a symlink and that's where the path was going wrong. Since that's not the case, can you clarify how the nas-server
relates to the git repo?
Do you mean \\nas-server\nas\Misc\temp repro\
is a path in the Nas server, that you have remapped as a drive letter mount to M:/Misc/temp repro
? Sorry, not that familiar with Windows.
from lint-staged.
We can try to make the realPath
call conditional based on stats.isSymbolicLink()
; maybe that will help.
from lint-staged.
I have no idea if the linked PR actually does anything, can you try it out? Based on what you said:
After messing around in the node repl, I learned that fs.realpath takes the path I'd expect to see (M:\Misc\temp repro.git) and transforms it into another path that works: \nas-server\nas\Misc\temp repro.git
I hope this means the git dir will be resolved to M:\Misc\temp repro\.git
and then normalized as M:/Misc/temp repro/.git
, which hopefully works.
from lint-staged.
Yeah, no symlinks involved.
nas-server
is another machine on my local network and \nas\Misc\temp repro
is a directory on that machine. I mapped \\nas-server\nas
to M:
on the machine I'm developing on, so M:/Misc/temp repro
is equivalent to \\nas-server\nas\Misc\temp repro
.
I tried the change in that PR and it worked! The directory resolves as expected and the staged file gets linted as expected. Thanks for all the help!
from lint-staged.
Thanks for debugging, I'll put it into the next release.
from lint-staged.
Related Issues (20)
- Unable to run `lint-staged` programmatically due to lack of types. HOT 2
- Warning when running ESLint with lint-staged: File ignored by default (for eslint cofniguration file) HOT 1
- Use another exit code for internal error.
- Running lint-stage inexplicably changes code HOT 1
- Unsupported engine warning in node 18.2.0 HOT 1
- exit with exit code 1 without printing anything HOT 5
- How to restore stash files into workspace when lint-staged error HOT 2
- Commits from Github Desktop occur errors HOT 4
- Not all lintstagedrc.json files are found in the rush.js monorepo HOT 4
- Type '(filenames: string[]) => Commands | Promise<Commands>' is not assignable to type 'string' HOT 2
- There is a bug with bracketed folders HOT 5
- Importing a reusable json file to ESM JS config fails HOT 1
- Path for baseConfig HOT 2
- lint-staged is unable to resolve path to module in Monorepo with map imports HOT 9
- Many errors in standard output when using git sparse-checkout HOT 4
- `--all` flag HOT 3
- lint-staged repeat many time ,when commit in windows powershell,cmd HOT 2
- [feat] override the current pattern HOT 1
- Make lint-staged more compatible with git sparse checkout feature HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lint-staged.