100 Commits

Author SHA1 Message Date
hashicorp-copywrite[bot]
36a312ee26
add missing license headers and update copyright file headers to BUS-1.1 2023-08-10 21:53:25 +01:00
Darragh Bailey
0c6d6d8e9d Improve Gem spec selection when resolving
When computing the solution set, if a gem is already loaded, make sure
to use the specification of the loaded one instead of the first
available as otherwise there is a risk that when multiple matches are
available the specification for the wrong version may be picked.

When this happens an error message will be triggered that looks like

  can't activate json-2.3.0, already activated json-2.5.1

This can occur for distribution packaged vagrants as well as installs
for development purposes where the ruby install may contain a default
gem spec of an older version than is needed.

Fixes: #12521
Fixes: vagrant-libvirt/vagrant-libvirt#1390
2021-11-01 17:31:48 +00:00
Chris Roberts
7362ac52e4 Fix dependency resolution where default gems are included
Parts of the stdlib which have been externalized but are still
    included within Ruby introduce issues when pinning Vagrant's
    dependencies to resolve plugin installs. When determining
    Vagrant's dependency list prior to solution generation, check
    the specification and ignore any default gems to prevent
    pinning versions that are not actual dependencies.
2021-03-25 12:35:33 -07:00
Chris Roberts
55dc18cb96 Default the builtin specs when initializing 2021-03-08 17:14:14 -08:00
Chris Roberts
32f4951759 Activate builtin specs during startup
When starting up, and before any loading, find our current
    specification and activate all the internal dependencies
    while also collecting the activated specifications. Store
    these for later use when doing plugin resolutions. We bypass
    the builtin list when running in bundler since they will
    still show up as not activated, but we use the entire list
    regardless.
2021-03-08 16:25:13 -08:00
Chris Roberts
282dadf784 When not running inside bundler, only use specifications that are activated 2021-03-08 15:58:47 -08:00
Chris Roberts
c4eda3f08f Update solution file to use DependencyRequests and allow prerelease
Maintain the solution file persisting dependency information on
    disk but update the runtime representation to
    Gem::Resolver::DependencyRequest instances which are expected
    by the sets when locating matches.

    Properly abide by prerelease setting in customized sets and
    force prerelease matching when in the builtin set. If a request
    is matched on a prerelease, and the request itself is not set
    to allow prereleases, update it to ensure successful resolution.
2020-11-17 13:02:33 -08:00
Chris Roberts
b479e04eb4 Request sets need prerelease enabled not just the spec matching 2020-11-06 15:22:28 -08:00
Chris Roberts
18c1607c6e Check dependency list on initialization
When initializing for internal plugin resolution inspect contraints
on all defined dependencies. If a prerelease constraint is detected,
automatically enable prerelease resolution.
2020-11-06 09:07:51 -08:00
Chris Roberts
5003bb6e15 Updates to address all Ruby deprecations and warnings
This includes updates for resolving all warnings provided by Ruby
for deprecations and/or removed methods. It also enables support
for Ruby 2.7 in the specification constraint as all 2.7 related
warnings are resolved with this changeset.
2020-08-10 13:05:41 -07:00
Chris Roberts
5195bee9ea Check if plugin install provides specification
During a plugin install, if the plugin is already installed and
activated, no specification will be returned as there was nothing
new installed. In this situation, look for the requested plugin
within the activated specifications. If it is found, then proceed
since the plugin is installed. If it is not found, return an error.
2020-05-06 15:51:37 -07:00
Chris Roberts
307d7f70b6 Allow prerelease matches when Vagrant is a prerelease version
Sets prerelease on the request set based on Vagrant's version. This
allows installing plugins which may include a vagrant version constraint
when running on a development version without needing to a manual local
installation of the gem.
2020-05-01 16:05:49 -07:00
Chris Roberts
21e5913cef Explicitly activate vagrant specification when not activated 2020-03-10 15:08:56 -07:00
Chris Roberts
d96f7c4293 Fix documentation disable in generation hooks 2020-03-09 16:52:39 -07:00
Chris Roberts
351e053aeb Start adding test coverage to bundler class 2020-03-09 16:52:39 -07:00
Chris Roberts
21c1bb5e05 Add support for caching solutions. Remove GEMRC modifications.
This pull request adds an enhancement to the internal Bundler class
to cache solution sets. This prevents Vagrant from generating a
solution for configured plugins on every run. Modifications to
the configured plugin list (global or local) will result in the
cached solution being invalidatd and resolved again.

Also included is the removal of the GEMRC modifications required
for Windows.
2020-02-03 07:43:17 -08:00
Chris Roberts
bbd75ef25a
Merge pull request #10896 from chrisroberts/f-plugin-constraints
Properly generate dependency instance when multiple constraints provided
2019-06-05 14:01:48 -07:00
Chris Roberts
109214f89d Properly generate dependency instance when multiple constraints provided 2019-06-05 13:46:42 -07:00
Chris Roberts
07b9f39a54 Clean up gem sources modifications
Based on suggestions from @zenspider here:
3daf3e532d (r33408747)
2019-06-05 09:36:37 -07:00
Chris Roberts
062ef52816 Handle strict dependency enforcement when installed within system
When installed outside of the official installer and not running
within a bundler environment, properly activate core dependencies
and properly enforce constraints.
2019-06-05 07:45:07 -07:00
Brian Cain
757175b94e
Add note about removing patch fix and add test 2019-04-22 10:36:25 -07:00
Brian Cain
e2097be55e
Fixes #10800, Fixes #9148: Ensure rubygems is loading gemrc properly on Windows
Prior to this commit, when Vagrant attempted to use the Gem library, it
would attempt to pass in a gemrc through an environment variable that
the rubygems library would try to split and parse. This is normally
fine, as the method in question would return empty if that file did not
exist. However if the user had a file that matches the drive that
Vagrant was installed on, rubygems would fail saying the folder was not
a file (or a gemrc, in this case).

This commit works around that by instead configuring the gemrc location
through ruby with `Gem.configuration`.

Related rubygems issue
[#2733](https://github.com/rubygems/rubygems/issues/2733)
2019-04-19 17:07:49 -07:00
Chris Roberts
3daf3e532d Update ordering of gem sources to ensure proper resolution
In recent Rubies the first dependency to satisfy the constraint will
be used regardless if higher versions are available in subsequent
sources. Move custom source to start of list when resolving plugins
to provide desired behavior.
2018-11-02 09:14:27 -07:00
Chris Roberts
3223737734 Use env_local consistently internally 2018-07-17 14:49:41 -07:00
Chris Roberts
b71054502e Update local usage to env_local for clarity 2018-07-17 14:49:41 -07:00
Chris Roberts
40f4e6f67e Vagrant Environment isolated plugins
Adds support for plugins isolated to a specific `Vagrant::Environment`
which can be managed by the vagrant plugin command using the the
--local flag.
2018-07-17 14:49:41 -07:00
Chris Roberts
91018d4edc Remove existing items from request set prior to installation 2018-05-08 13:52:23 -07:00
Josh Soref
1a5ddea9f4 Spelling fixes
* account
* addresses
* administrator
* afterwards
* because
* bridgeable
* capabilities
* capability
* checksum
* configuration
* configuration for
* configure
* criteria
* delimited
* delivered
* derivatives
* description
* detect
* directory
* display
* downloading
* during
* electric
* enabling
* encountered
* equivalent
* executable
* executed
* hashicorp
* hypervisor
* hyphens
* implementation
* incorporate
* inheritance
* initialize
* instance
* instead
* interactions
* invocable
* machine
* maximum
* message
* mounting
* overridden
* overwrite
* paramiko
* preparing
* provides
* provisioning
* recursively
* requested
* resetting
* retryable
* running
* satisfied
* searching
* sometimes
* specified
* successfully
* synced folders
* unauthorized
* underlying
* userprofile
* vagrant
* vagrantfile
* variable
* various
* version
* virtual
* windows
2018-03-14 14:41:04 +00:00
Chris Roberts
f42279508d Reset plugin constraint on update if explicit version set 2017-06-28 07:24:32 -07:00
Chris Roberts
73d85bd2f7 Support strict enforcement of internal dependency constraints 2017-06-27 19:20:20 -07:00
Chris Roberts
85d5f11f62 Adjustments to handle plugin updates using proper constraints
If a user provides the gem version using an explicit version or a
constraint, the update action should honor that constraint and not
simply replace it with an unbound constraint.

This also removes system plugin specifications from being matched
and preferred which prevents updates and can result in unexpected
downgrades when running the update.
2017-06-27 19:05:30 -07:00
Chris Roberts
6aafe3255a Force wrappers to be generated to prevent invalid version parsing 2017-04-06 16:52:10 -07:00
Chris Roberts
df069deac0 Validate plugin sources and report errors if detected. 2017-04-04 17:53:04 -07:00
Chris Roberts
354c1c2b51 Prevent adding local paths to RubyGems sources list 2017-03-22 16:36:42 -07:00
Chris Roberts
9d1ec938ef Merge pull request #8341 from chrisroberts/enhancement/prerelease
Support spec prerelease matching
2017-03-07 15:02:17 -08:00
Chris Roberts
7610ecfcba Allow prerelease matches on vagrant spec when running instance is prerelease 2017-03-07 10:36:35 -08:00
Chris Roberts
96204383c7 Force path as preferred source on local install 2017-03-03 09:12:44 -08:00
Chris Roberts
86af6501ed Remove installer set push from default source push 2017-02-24 08:02:22 -08:00
Chris Roberts
70cacb27fa Prefer given source if available when installing plugin 2017-02-09 17:22:48 -08:00
Michael Brandt
be63ace50f Add gem_version to plugin_info for local installs 2017-02-02 17:58:29 -07:00
Chris Roberts
df00edf1a7 Set base directory to parent directory within plugin specs
This adjustment allows for extensions to be properly discovered after
plugin gem specifications have been activated.
2017-01-06 12:55:13 -08:00
Chris Roberts
c8d564e578 Prevent interaction when removing plugin gems 2016-12-06 07:07:52 -08:00
Chris Roberts
5b1b18d01a Merge pull request #8068 from chrisroberts/bundler/install-solution-act
Detect load failure within solution set and retry if found
2016-12-05 13:28:58 -08:00
Chris Roberts
3dccd82a39 Explicitly require name_tuple
This does not get automatically loaded before usage so ensure
it is properly loaded for plugin usage.
2016-12-05 09:35:02 -08:00
Chris Roberts
ce35611c34 Detect load failure within solution set and retry if found
Installation solution sets in 2.2.5 can end up out of order (not seen
in 2.3.1) causing LoadErrors when the specification is in the solution
set during validation. This detects the missing spec within the solution
and if found will move spec to the start of the solution set and retry
solution activation.
2016-12-01 08:15:04 -08:00
Chris Roberts
f1e623976b Do not include default specifications within dependencies 2016-11-28 16:54:59 -08:00
Chris Roberts
2cc4b82198 Only read default specifications directory when within bundler context 2016-11-22 08:26:43 -08:00
Chris Roberts
a51949933f Always apply builtin constraints within dependency restrictions
Include detection of running context (within Bundler or not) and
load the "buitin" gems based on that context.
2016-11-22 07:53:19 -08:00
Chris Roberts
53b9f1747c Allow plugin_init_error to provide all information. Include final reset on specifications. 2016-11-17 16:40:51 -08:00
Chris Roberts
818f7acb7b Provide better internal consistency of installed plugin gems.
Refactors reusable actions into isolated methods. Supports installation/removal
without activation to prevent unintended conflicts during upgrades and cleanup.
Introduced custom resolver set to handle multiple installed versions of gems
which enables proper cleanup.
2016-11-16 13:26:13 -08:00