Skip to content

Commit

Permalink
fix: sync packages if "hermit install" fails to find a package
Browse files Browse the repository at this point in the history
This occasionally breaks enabling the hermit IntelliJ plugin that installs dependencies automatically at startup.

We also skipt the test if we had synchronized previously if we are forcing a sync.
This is needed as "hermit install" does a non forced sync at the beginning, marking source as synced, and this prevents the later forced sync from running when the package is not found.
  • Loading branch information
jvmakine committed May 15, 2024
1 parent f62cbde commit 460ecbf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/install_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (i *installCmd) Run(l *ui.UI, env *hermit.Env, state *state.State) error {
// Checking that all the packages are downloaded and unarchived
for _, ref := range installed {
task := l.Task(ref.String())
pkg, err := env.Resolve(l, manifest.ExactSelector(ref), false)
pkg, err := env.Resolve(l, manifest.ExactSelector(ref), true)
if err != nil {
return errors.WithStack(err)
}
Expand Down
5 changes: 3 additions & 2 deletions sources/sources.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package sources

import (
"github.com/cashapp/hermit/util"
"io/fs"
"net/url"
"os"
"path/filepath"
"strings"
"time"

"github.com/cashapp/hermit/util"

"github.com/cashapp/hermit/errors"
"github.com/cashapp/hermit/ui"
)
Expand Down Expand Up @@ -55,7 +56,7 @@ func (s *Sources) Add(source Source) {
// Will be synced at most every SyncFrequency unless "force" is true.
// A Sources set can only be synchronised once. Following calls will not have any effect.
func (s *Sources) Sync(p *ui.UI, force bool) error {
if s.isSynchronised {
if s.isSynchronised && !force {
return nil
}
s.isSynchronised = true
Expand Down

0 comments on commit 460ecbf

Please sign in to comment.