27 Commits

Author SHA1 Message Date
Jack Nagel
72d83adaf3 Adjust link command for updated error handling 2014-04-21 12:43:06 -05:00
Jack Nagel
1f0d424459 link: fix output ordering when exceptions are raised 2014-03-27 16:27:46 -05:00
Jack Nagel
3a48d7ab9b link: print wrapper is not always required 2014-03-27 16:27:46 -05:00
Jack Nagel
714bfee8d9 Add missing newline to link and unlink in verbose mode 2014-03-26 21:53:34 -05:00
Adam Vandenberg
4c9ac19e87 Consolidate sudo checks.
Closes Homebrew/homebrew#20318.
2013-06-08 20:44:56 -07:00
Jack Nagel
92b6bcb77d link: extract keg-only check into a helper method 2013-05-20 21:55:01 -05:00
Jack Nagel
951b09b1c5 link: eliminate naked rescue 2013-04-10 12:02:35 -05:00
Jack Nagel
aa58a404ed Fix another handful of warnings 2013-04-06 00:14:03 -05:00
Adam Vandenberg
0dec35e7b0 Only check keg-only if we map to a formula 2013-01-29 20:45:33 -08:00
Adam Vandenberg
40c339e349 Require --force to link keg-only.
Closes Homebrew/homebrew#13349.
2013-01-29 20:31:33 -08:00
Jack Nagel
37a56fa513 FormulaInstaller: implement installation locks
FormulaInstaller now attempts to take a lock on a "foo.brewing" file for
the formula and all of its dependencies before attempting installation.

The lock is an advisory lock implemented using flock(), and as such it
only locks out other processes that attempt to take the lock. It also
means that it is never necessary to manually remove the lock file,
because the lock is not enforced by I/O.

The uninstall, link, and unlink commands all learn to respect this lock
as well, so that the installation cannot be corrupted by a concurrent
Homebrew process, and keg operations cannot occur simultaneously.
2013-01-26 12:14:45 -06:00
Adam Vandenberg
e99ca2d59f Add relinking instructions.
Closes Homebrew/homebrew#15488.
2012-10-22 12:27:17 -07:00
Misty De Meo
447f78c0d2 brew ln --force is now brew ln --overwrite
* Renames --force to --overwrite, freeing up brew ln --force for Homebrew/homebrew#13349
* Changes --dry-run to preview linking by default, rather than
  overwriting. An overwrite dry-run can be simulated via both
  --dry-run --overwrite
* Adds some basic Keg tests
2012-10-20 21:00:46 -05:00
Max Howell
45b84df1bd Be more verbose when users insist on being sudoers
If you google for "Cowardly refusing to sudo brew" you get a lot of confused users who didn't read any of the Homebrew documentation and then had a hissy-fit.
2012-08-10 09:33:44 -04:00
Adam Vandenberg
1b37ed4269 use keg.linked? 2012-07-11 20:13:46 -07:00
Misty De Meo
f17429f842 ARGV: add .dry_run? method
Add an ARGV.dry_run? helper method for '--dry-run'/'-n' now that
'-n' is being used as a git-style dry-run in two commands.

Closes Homebrew/homebrew#12898.

Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
2012-07-09 12:01:09 -05:00
Misty De Meo
743b5e6feb link: add --force and --dry-run options
`brew link` can now be made to delete any conflicting files using
the --force argument. It also has a --dry-run option, similar to
git clean -n, which will list any files which would be deleted
without touching the filesystem.

Closes Homebrew/homebrew#11811.

Signed-off-by: Misty De Meo <mistydemeo@gmail.com>
2012-07-09 12:01:09 -05:00
Jack Nagel
ed83fa609b Remove broken puts from verbose brew link
The print wrapper which has its own `puts` broke this line; though with
the changes to `link` it isn't necessary any longer, so just remove it.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-03-20 11:24:35 -05:00
Max Howell
88118b51b2 Don't error if exact link already exists
If the link already exists exactly (well almost exactly) as we are about to correct it, then it's okay. Otherwise we error out. This is a safe choice, and really, the correct choice too.

This will prevent the tickets like Homebrew/homebrew#11050 from occurring.
2012-03-19 12:24:13 +00:00
Max Howell
c3370c48ce Better error when linking fails
Refs http://stackoverflow.com/questions/9762943

The system ln no longer outputs anything. Though the user can force its output with a --verbose of course. So in cases where it's not the usual of: not writable or existing file, we can ask the user to run with --verbose. I don't particularly like hiding its output, but it just confused the error IMO since it is creating a relative symlink the output was weird every time I've seen it in tickets.

I made a print wrapper so that the brew-link output doesn't get mucked up if an exception is thrown.
2012-03-19 00:28:38 +00:00
Max Howell
765ae96180 Leave kegs keg-only if linking step fails
Rationale: well, it should always have been like this!

However now we are opening ourselves up to more-mixed installations of formula not maintained by us, it's important that
2012-03-16 21:06:16 +00:00
Max Howell
f7d7fb1e81 Don't allow brew link to be run as sudo 2012-03-04 02:47:53 +00:00
Jack Nagel
1a3a1249bf Warn the user of required arguments
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-02-04 00:27:05 -06:00
Jack Nagel
59458eac51 link: add missing newline in verbose mode
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2012-02-01 22:52:14 -06:00
Max Howell
1f95b07ba5 Fix keg exception pretty output 2011-08-24 22:30:43 +01:00
Max Howell
471dc987e5 Specify that they are symlinks 2011-08-22 10:26:01 +01:00
Max Howell
768910283a Refactor the brew command into one file per command
The code was sucking. To the extent that maintenance was hard. It's a lot
easier to work with code that is sensibly split at sensible boundaries. So
now it is more like that.

But the refactor is minimal. Because we don't want you to have more merge
hell than absolutely necessary.

If you merge you will need to pay attention to brew.h.rb (as it is deleted)
and bin/brew (as command logic is gone). It will be painful, but you will just
have to help git out by moving any changes around manually.

Note compatibility.rb. It ensures that any function renames or removals don't
break anything. We're pretty serious about backwards compatibility. And that's
because we encourage you to hack around with the innards. And we couldn't do
that if we would then just make stuff disappear behind your back.
2011-03-12 11:55:02 -08:00