Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sysfs/fixtures filenames are too long #57

Closed
F21 opened this issue Jun 20, 2017 · 23 comments
Closed

sysfs/fixtures filenames are too long #57

F21 opened this issue Jun 20, 2017 · 23 comments

Comments

@F21
Copy link

F21 commented Jun 20, 2017

Trying to install github.com\prometheus\client_golang\prometheus using glide which has procfs as a dependency.

The install fails on windows because sysfs/fixtures contains subfolders with long filenames:

Cloning into 'C:\Users\user\.glide\cache\src\https-git.f4.workers.dev-prometheus-procfs'...
error: unable to create file sysfs/fixtures.src/devices/pci0000_@colon@_00/0000_@colon@_00_@colon@_0d.0/ata4/host3/target3_@colon@_0_@colon@_0/3_@colon@_0_@colon@_0_@colon@_0/block/sdb/bcache/stats_day/cache_bypass_misses: Filename too long
error: unable to create file sysfs/fixtures.src/devices/pci0000_@colon@_00/0000_@colon@_00_@colon@_0d.0/ata4/host3/target3_@colon@_0_@colon@_0/3_@colon@_0_@colon@_0_@colon@_0/block/sdb/bcache/stats_day/cache_miss_collisions: Filename too long
fatal: cannot create directory at 'sysfs/fixtures.src/devices/pci0000_@colon@_00/0000_@colon@_00_@colon@_0d.0/ata4/host3/target3_@colon@_0_@colon@_0/3_@colon@_0_@colon@_0_@colon@_0/block/sdb/bcache/stats_five_minute': Filename too long
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry the checkout with 'git checkout -f HEAD'

ref #55 #56

@F21
Copy link
Author

F21 commented Jun 20, 2017

Workaround:

  • Enable long paths on Windows (requires Windows 10 Anniversary Update or newer): https://superuser.com/a/1119980/97078
  • Configure git to use long paths: git config --global core.longpaths true (globally) or git config core.longpaths true (per project)

@F21
Copy link
Author

F21 commented Jun 20, 2017

Still having issues after using the workaround:

[ERROR] Unable to export dependencies to vendor directory: chmod C:\Work\src\github.com\F21\some_project\vendor\github.com\prometheus\procfs\sysfs\fixtures.src\devices\pci0000_@colon@_00\0000_@colon@_00_@colon@_0d.0\ata4\host3\target3_@colon@_0_@colon@_0\3_@colon@_0_@colon@_0_@colon@_0\block\sdb\bcache\dirty_data: The system cannot find the path specified.

@ideaship
Copy link
Contributor

65 chars: C:\Users\user\.glide\cache\src\https-git.f4.workers.dev-prometheus-procfs
192 chars: sysfs/fixtures.src/devices/pci0000_@colon@_00/0000_@colon@_00_@colon@_0d.0/ata4/host3/target3_@colon@_0_@colon@_0/3_@colon@_0_@colon@_0_@colon@_0/block/sdb/bcache/stats_day/cache_bypass_misses
194 chars: sysfs/fixtures.src/devices/pci0000_@colon@_00/0000_@colon@_00_@colon@_0d.0/ata4/host3/target3_@colon@_0_@colon@_0/3_@colon@_0_@colon@_0_@colon@_0/block/sdb/bcache/stats_day/cache_miss_collisions
180 chars: sysfs/fixtures.src/devices/pci0000_@colon@_00/0000_@colon@_00_@colon@_0d.0/ata4/host3/target3_@colon@_0_@colon@_0/3_@colon@_0_@colon@_0_@colon@_0/block/sdb/bcache/stats_five_minute
65+1+192=258
65+1+194=260
65+1+180=246
The length limitation for paths on Windows is said to be 260 characters. I don't understand why this paths are too long, even on Windows -- unless the first, absolute path is not the root from where the relative paths start.

Of course we could shorten the code used to replace colon from _@colon@_ to something shorter. Even taking into account my insufficient understanding of the problem (see above), I suppose that would fix it at least for these paths. Of course, a longer username in the path might break it again.

The chmod problem I have no idea about.

Perhaps we should consider going back to tar. My approach may be too brittle on Windows.

What are people using on Windows these days, anyway? Cygwin? The Linux subsystem for Windows?

@grobie
Copy link
Member

grobie commented Jun 20, 2017

Let's just use a comma inst of _@colon@_? @F21 Could you check whether that's ok?

@F21
Copy link
Author

F21 commented Jun 20, 2017

I think the length issue can be easily solved if you're on Windows 10. See my comment here: #57 (comment)

I tried using glide and dep and they both had the same issue with chmod. I had some discussions with @sdboyer and he reckons os.Chmod() might not be cross platform. I have a feeling that the main culprit is probably the @ causing the chmod to fail.

@F21
Copy link
Author

F21 commented Jun 20, 2017

@grobie If a comma works for you guys, it should be cool :) However, I am not sure whether os.Chmod() will work correctly with commas. Have you guys considered using a dash (-) or even -colon-?

@grobie
Copy link
Member

grobie commented Jun 20, 2017

I'd be afraid to use a dash as replacement separator, it's too common in filenames.

@F21
Copy link
Author

F21 commented Jun 20, 2017

How about two underscores: __colon__?

@grobie
Copy link
Member

grobie commented Jun 20, 2017

That's still making filenames very long. I don't think it's reasonable to expect everyone checking out the repository on Windows to have Windows 10 and able to change their filesystem configuration.

@grobie
Copy link
Member

grobie commented Jun 20, 2017

I meant a literal comma ,.

@F21
Copy link
Author

F21 commented Jun 20, 2017

Ah, I see. I think a comma should be fine as I do have files with commas in them on the filesystem and they seem to work fine.

@grobie
Copy link
Member

grobie commented Jun 20, 2017

Thanks so much for reporting and being so responsive @F21. I'll put something together, given I don't have access to a Windows node, would you be able to test another fix for us?

@ideaship
Copy link
Contributor

Every single character is a liability going forward. There are files in /sys that already contain dashes, commas, at signs, underscores, periods, and parentheses. Are we sure that no such file will turn up in the fixtures directory at some point?

@grobie
Copy link
Member

grobie commented Jun 20, 2017

If you know there are commas already, that's not an option. @ideaship so let's revert and be safe and go with the tarball approach?

@F21
Copy link
Author

F21 commented Jun 20, 2017

Also, another liability is that the repo might not be checked out to C:/Users/someuser/....

In my case, glide or dep checks them out to C:/Users/someuser/appdata/temp/... and then copies them into my workspace, which is D:/000-Work/go/src/github.com/somecompany/someproject, which can have a very long path.

@F21
Copy link
Author

F21 commented Jun 20, 2017

@grobie Happy to test your fix 😄 once it's pushed.

@ideaship
Copy link
Contributor

I'd say let's go back to the tar ball. It seems to be pretty much the only way to be safe.

@ideaship
Copy link
Contributor

Oh, and @F21: I'd still be interested to learn what you are using as an environment on Windows (cygwin, Linux subsystem for Windows, ...).

@grobie grobie closed this as completed in 822d4a1 Jun 20, 2017
@F21
Copy link
Author

F21 commented Jun 20, 2017

@ideaship I am mostly using Git Bash and occasionally just the standard shell (CMD) for most things. I did play around with Bash for Windows, but there are still some rough edges, so it's not my main shell yet.

@F21
Copy link
Author

F21 commented Jun 20, 2017

I just ran dep init to install my dependencies with a clean cache. I will report back once it's done.

@F21
Copy link
Author

F21 commented Jun 20, 2017

@ideaship @grobie Thanks for pushing the fix! I can confirm it works correctly! 😄

@grobie
Copy link
Member

grobie commented Jun 20, 2017 via email

@whendream
Copy link

Workaround:

  • Enable long paths on Windows (requires Windows 10 Anniversary Update or newer): https://superuser.com/a/1119980/97078
  • Configure git to use long paths: git config --global core.longpaths true (globally) or git config core.longpaths true (per project)

thank you so much!!!it worked!!

remijouannet pushed a commit to remijouannet/procfs that referenced this issue Oct 20, 2022
The generated pathnames are too long for some filenames, including NTFS
in its default configuration. We've considered using other separators,
but deemed shorter ones to easy to break something.

This reverts commit b9955ae, reversing
changes made to a3bfc74.

Fixes prometheus#57.
bobrik pushed a commit to bobrik/procfs that referenced this issue Jan 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants