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

Automatically modify $PATH with /etc/paths.d #3597

Closed
szhu opened this issue Mar 18, 2014 · 15 comments
Closed

Automatically modify $PATH with /etc/paths.d #3597

szhu opened this issue Mar 18, 2014 · 15 comments

Comments

@szhu
Copy link
Contributor

szhu commented Mar 18, 2014

MacTeX and some other software packages install binaries to non-standard locations. This necessitates caveats like the one added by #2284:

==> Caveats
To use mactex, you may need to add the /usr/texbin directory
to your PATH environment variable, eg (for bash shell):

  export PATH=/usr/texbin:"$PATH"

There's actually a really elegant solution to appending to $PATH on OS X: Just add a file with the path to append in /etc/paths.d. When shells start, they run path_helper, which parses /etc/path and the files in /etc/paths.d to construct the correct $PATH. Such a "path file" would be easy for Homebrew to install and uninstall. Or, alternatively, a Cask "path file" could be installed that would contain all the paths of the currently installed formulae.

Not only does this solution automate something that users would need to do by hand, but also it is, unlike the solution recommended by the caveat note, both auto-uninstallable and shell-agnostic.

@rolandwalker
Copy link
Contributor

+1 for adding the capability within homebrew-cask.

For this specific package -- I believe that MacTeX already does create a file under /etc/paths.d.

@szhu
Copy link
Contributor Author

szhu commented Mar 18, 2014

If MacTeX already creates the file, then why is the caveat needed?

@rolandwalker
Copy link
Contributor

Excellent question! We need to check closer.

This is a particularly slow one to install/uninstall, so I'm sure it will be at least a few days before we come around to testing it.

@szhu
Copy link
Contributor Author

szhu commented Mar 19, 2014

Haha, I've been trying to install it for a few days and I still haven't managed to download it intact.

@szhu
Copy link
Contributor Author

szhu commented Mar 19, 2014

On a related note, any particular reason this download is so slow? Are there any faster mirrors available?

@szhu
Copy link
Contributor Author

szhu commented Mar 19, 2014

Finally installed. It looks like MacTeX installs /etc/paths.d/TeX, making the caveat unnecessary. If someone can confirm this, I can submit a PR.

Related questions:

  1. Homebrew wants /usr/local/sbin to be in $PATH. Would it be a good idea to add it to paths.d if brew --prefix is /usr/local?
  2. XQuartz installs the file /etc/paths.d/40-XQuartz. Is there a purpose for the 40 that needs to be taken into consideration should paths.d-modification be built into Cask or Homebrew?

@rolandwalker rolandwalker self-assigned this Mar 20, 2014
@rolandwalker
Copy link
Contributor

Your research on this is greatly appreciated!

Now it is me waiting for the download. I've never found a really fast CTAN mirror either.

The 40 in the filename is an old-fashioned hack to control the order in which the path elements are added. Files are traditionally named by tens on the theory that you might need the ones place later to insert something between.

As to the Homebrew path, we try not to step on each others' toes. That setting would seem to make sense for users to do, or for Homebrew to do, but it shouldn't be part of this project.

@joethorley
Copy link

Finally installed. It looks like MacTeX installs /etc/paths.d/TeX, making the caveat unnecessary. If
someone can confirm this, I can submit a PR.

I can confirm that running the following code

brew tap phinze/cask
brew install brew-cask
brew cask install mactex

installs /etc/paths.d/TeX

with the contents

/usr/texbin

I can also confirm that brew cask install mactex took hours and required several attempts (which continued from where the previous attempt left off)

@goxberry
Copy link
Contributor

@rolandwalker I added the caveat to BasicTeX in #2311. The reason the caveat was added in the first place due to Homebrew/legacy-homebrew#25719; it affects zsh users, because a default Homebrew zsh configuration doesn't necessarily import paths from /etc/paths.d. The caveat is unnecessary for bash and fish users.

rolandwalker added a commit to rolandwalker/homebrew-cask that referenced this issue Mar 27, 2014
@alebcay
Copy link
Member

alebcay commented Apr 3, 2014

It seems this was addressed in v0.32.0 (pull request #3699). Should this be closed?

@szhu
Copy link
Contributor Author

szhu commented Apr 3, 2014

It's not completely addressed. From #3685 comment 38804186:

The original idea in #3597 was that we add the ability to manipulate the contents of /etc/paths.d. That still seems worth doing.

@rolandwalker
Copy link
Contributor

Yes, please keep this open as I am assigned and intend to implement.

@szhu
Copy link
Contributor Author

szhu commented Jun 21, 2014

Heads-up, BasicTex doesn't seem to install anything to /etc/paths.d like MacTex does (but I think it should, as otherwise some programs can't locate the installed commands).

For reference: basictex.rbmactex.rb

@rolandwalker
Copy link
Contributor

Thanks. Then that's the perfect use-case for this proposed feature.

@vitorgalvao
Copy link
Member

Closing for lack of interest/implementation. This is definitely non-urgent, and can be revisited later.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants