vim-surround icon indicating copy to clipboard operation
vim-surround copied to clipboard

Failed to load the vim-surround package when trying to install at the same time as vim-mode

Open darylrobbins opened this issue 9 years ago • 14 comments

[Enter steps to reproduce below:]

  1. Attempt to install vim-surround and vim at the same

Atom Version: 0.210.0 System: Mac OS X 10.10.3 Thrown From: vim-surround package, v0.7.2

Stack Trace

Failed to load the vim-surround package

At Cannot find module 'undefined/lib/text-objects'

Error: Cannot find module 'undefined/lib/text-objects'
  at Module._resolveFilename (module.js:328:15)
  at Function.Module._resolveFilename (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/module-cache.js:383:52)
  at Function.Module._load (module.js:270:25)
  at Module.require (module.js:357:17)
  at require (module.js:376:17)
  at Object.<anonymous> (/Users/daryl/.atom/packages/vim-surround/lib/command/selector.coffee:2:46)
  at Object.<anonymous> (/Users/daryl/.atom/packages/vim-surround/lib/command/selector.coffee:1:1)
  at Module._compile (module.js:452:26)
  at Object.requireCoffeeScript (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/coffee-cash/lib/coffee-cash.js:85:19)
  at Module.load (module.js:347:32)
  at Function.Module._load (module.js:302:12)
  at Module.require (module.js:357:17)
  at require (module.js:376:17)
  at Object.<anonymous> (/Users/daryl/.atom/packages/vim-surround/lib/command/delete.coffee:4:12)
  at Object.<anonymous> (/Users/daryl/.atom/packages/vim-surround/lib/command/delete.coffee:1:1)
  at Module._compile (module.js:452:26)
  at Object.requireCoffeeScript (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/coffee-cash/lib/coffee-cash.js:85:19)
  at Module.load (module.js:347:32)
  at Function.Module._load (module.js:302:12)
  at Module.require (module.js:357:17)
  at require (module.js:376:17)
  at Object.<anonymous> (/Users/daryl/.atom/packages/vim-surround/lib/vim-surround.coffee:4:10)
  at Object.<anonymous> (/Users/daryl/.atom/packages/vim-surround/lib/vim-surround.coffee:1:1)
  at Module._compile (module.js:452:26)
  at Object.requireCoffeeScript (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/coffee-cash/lib/coffee-cash.js:85:19)
  at Module.load (module.js:347:32)
  at Function.Module._load (module.js:302:12)
  at Module.require (module.js:357:17)
  at require (module.js:376:17)
  at Package.module.exports.Package.requireMainModule (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/package.js:709:34)
  at /opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/package.js:188:28
  at Package.module.exports.Package.measure (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/package.js:165:15)
  at Package.module.exports.Package.load (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/package.js:179:12)
  at PackageManager.module.exports.PackageManager.loadPackage (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/package-manager.js:372:14)
  at PackageManager.module.exports.PackageManager.activatePackage (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/package-manager.js:451:30)
  at /opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/settings-view/lib/package-manager.js:362:29
  at exit (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/settings-view/lib/package-manager.js:53:16)
  at triggerExitCallback (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/buffered-process.js:213:47)
  at /opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/buffered-process.js:220:18
  at Socket.<anonymous> (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/buffered-process.js:98:18)
  at emitOne (events.js:82:20)
  at Socket.emit (events.js:166:7)
  at Pipe.close (net.js:464:12)

Commands

     -0:25.9.0 settings-view:open (atom-text-editor.editor.is-focused)
     -0:19.5.0 core:confirm (atom-text-editor.editor.mini.is-focused)

Config

{
  "core": {
    "themes": [
      "one-light-ui",
      "github-2014"
    ]
  }
}

Installed Packages

# User
file-icons, v1.5.7
github-2014, v3.6.0
language-docker, v1.1.3
language-haml, v0.21.0
vim-surround, v0.7.2

# Dev
No dev packages

darylrobbins avatar Jun 19 '15 16:06 darylrobbins

Hrmmm.. Did it work after a restart?

gepoch avatar Jun 19 '15 16:06 gepoch

Yes, it appears to work fine after a restart. It seems to be a timing issue. I tried reproducing it a few times and it doesn't happen every time. Basically, the vim-mode install has to be part way complete when vim-surround tries to install. I'd say it's probably not worth fixing. It's more likely an Atom bug that a dependent plugin can be installed at the same time as its dependency.

darylrobbins avatar Jun 19 '15 16:06 darylrobbins

Well, that's kind of the weird thing. vim-surround USES vim-mode's provider, but it isn't strictly a dependency. It's the difference between accessing the vim-mode object that controls your session, and just depending on vim-mode as an installed library (which is kind of unnecessary overhead.)

I'd prefer to fix this, and I bet there's a way to! I'll leave this ticket open for now. Vim-surround should be as smooth as possible.

gepoch avatar Jun 19 '15 17:06 gepoch

If you want to try and reproduce, click install on vim-mode and then click on vim-surround immediately after -- like you are quickly reinstalling your favourite plugins.

darylrobbins avatar Jun 19 '15 19:06 darylrobbins

Just happened to me too

liquiddandruff avatar Jun 27 '15 00:06 liquiddandruff

So this is weird... When I have vim-mode disabled and vim-mode-next enabled, everything works perfectly (as it should).

So I uninstall vim-mode and restart Atom. This should not change anything, right? It's disabled!

Now vim-surround throws this Cannot find module 'undefined/lib/text-objects' error 100% of the time.

I reinstall vim-mode, immediately disable it, and restart Atom. The error is gone. 100% reproducible.

So why does having vim-mode installed but disabled on my machine make this error go away? I don't know but I hope an additional datapoint might help.

bronson avatar Jul 04 '15 01:07 bronson

I would guess that disabling a plugin leaves the plugin in tact in the filesystem but just no longer calls its initializer to make it 'active'. So, when the vim-mode plugin is present but disabled, vim-surround is successfully able to find modules within it, even though the vim-mode plugin is not running per se.

darylrobbins avatar Jul 04 '15 20:07 darylrobbins

Agreed. That would be unfortunate if true... that doesn't sound very disabled. :)

bronson avatar Jul 04 '15 20:07 bronson

If you think of it in terms of the average plugin that isn't really depended upon by anything, disabled would mean disabled. When it is depended on though, all sort of havoc could potentially ensue from the dependent plugin assuming that its dependency is live. In this particular case though, since vim-surround is depending on vim-mode to call it, the havoc should be minimal.

darylrobbins avatar Jul 04 '15 20:07 darylrobbins

True, but that goes against Atom's any plugin can implement any functionality design goal... In this case, only vim-mode can supply the functionality that vim-surround needs. If you run an alternative vim, even if it provides everything that vim-surround needs, it won't work.

As you say, this problem is mostly theoretical for now.

bronson avatar Jul 04 '15 20:07 bronson

Agreed. I'm not saying it's the best long-term choice. I'm merely engaging in informed speculation as to why you might be seeing the behaviour you describe. :)

darylrobbins avatar Jul 04 '15 20:07 darylrobbins

Interesting! Yeah, I'd agree with daryirobbins here. We need to use the active vim-mode object in order to do some of our text selections. Since it isn't truly a dependency, we resolve the (presumably) installed vim-mode path with:

vimModePath = atom.packages.resolvePackagePath('vim-mode')
{SelectInsideQuotes, SelectInsideBrackets} = require "#{vimModePath}/lib/text-objects"

As you can tell, this isn't going to work with vim-mode-next unless we explicitly decide to fall back to it. There might be a way to get around this using "services" (which could be a sort of trait-based description of a package) to access the methods instead.

Definitely something to look at! I might create a new ticket to track this pan-vim-modes compatability.

gepoch avatar Jul 06 '15 14:07 gepoch

@gepoch I'm still getting this error when atom starts up. Any workaround?

Thanks.

eyaleizenberg avatar Aug 27 '17 07:08 eyaleizenberg

Hey @eyaleizenberg the vim-mode package was officially deprecated in favor of the much better vim-mode-plus plugin! Vim-mode-plus implements its own surround functionality, so my vim-surround plugin is obsolete. See https://github.com/gepoch/vim-surround/issues/40 for some more info on vim-mode-plus, and how to set up its surround keybindings.

gepoch avatar Aug 28 '17 21:08 gepoch