slackapi / hubot-slack

Slack Developer Kit for Hubot
https://slack.dev/hubot-slack/
MIT License
2.3k stars 634 forks source link

hubot@>4.0.0 Cannot load adapter #653

Open jdoss opened 12 months ago

jdoss commented 12 months ago

Any version of Hubot greater than 4.0.0 can no longer use this adapter.

$ npm list -g
/usr/local/lib
+-- coffeescript@1.11.1
+-- corepack@0.18.0
+-- generator-hubot@0.4.0
+-- hubot-diagnostics@1.2.0
+-- hubot-plusplus@1.4.0
+-- hubot-redis-brain@1.0.0
+-- hubot-slack@4.10.0
+-- hubot-yubikey-invalidation@0.0.3
+-- hubot@5.0.6
+-- npm@9.6.7
`-- yo@4.3.1

node@35a610129064:~$ hubot
{"level":50,"time":1688759766927,"pid":194,"hostname":"35a610129064","name":"hubot","msg":"Cannot load adapter [no path set] slack - /usr/local/lib/node_modules/hubot-slack/src/bot.coffee:22:10: error: unexpected newline\n    super\u001b[1;31m\u001b[0m\n\u001b[1;31m         ^\u001b[0m"}

I had pin the following versions to get things working again.

npm install -g yo generator-hubot coffeescript@1.11.1 hubot@"<4.0.0" hubot-slack hubot-plusplus hubot-redis-brain hubot-diagnostics hubot-yubikey-invalidation
node@35a610129064:~$ npm list -g
/usr/local/lib
+-- coffeescript@1.11.1
+-- corepack@0.18.0
+-- generator-hubot@0.4.0
+-- hubot-diagnostics@1.2.0
+-- hubot-plusplus@1.4.0
+-- hubot-redis-brain@1.0.0
+-- hubot-slack@4.10.0
+-- hubot-yubikey-invalidation@0.0.3
+-- hubot@3.5.0
+-- npm@9.6.7
`-- yo@4.3.1

node@35a610129064:~$ hubot
[Fri Jul 07 2023 20:04:28 GMT+0000 (Coordinated Universal Time)] INFO hubot-slack adapter v4.10.0
warn: SlackDataStore is deprecated and will be removed in the next major version. See project documentation for a migration guide.
warn: SlackDataStore is deprecated and will be removed in the next major version. See project documentation for a migration guide.
[Fri Jul 07 2023 20:04:28 GMT+0000 (Coordinated Universal Time)] ERROR No token provided to Hubot
zimeg commented 12 months ago

Hey @jdoss! Thank you for sharing this issue as well as a workaround for it!

Since this project is no longer under active development, there are no immediate plans to support the latest versions of Hubot. However, since others might encounter this same issue we can keep this issue open for now.

Really appreciate your investigation into this, and I also hope pinning to <4.0.0 is suitable for the bot you're building!

jdoss commented 12 months ago

No problem @zimeg. Pinning to 4.0.0 works fine for my needs as I have an group of old coworkers in a slack and we can't seem to live without the hubot-plusplus plugin in our chat.

joeyguerra commented 10 months ago

I created a new Slack adapter for use with the latest Hubot version if you're interested in updating. I know it might be some work to update, though. Let me know how I can help.

evercast-mahesh2021 commented 9 months ago

I am also facing different issues while trying hubot-slack adapter.

npm list -g

/usr/local/lib
├── coffeescript@1.11.1
├── corepack@0.19.0
├── generator-hubot@0.4.0
├── hubot-diagnostics@1.2.0
├── hubot-plusplus@1.4.0
├── hubot-redis-brain@2.0.0
├── hubot-slack@4.10.0
├── hubot-yubikey-invalidation@0.0.3
├── hubot@3.5.0
├── n@9.1.0
├── npm@10.0.0
├── slack@11.0.2
└── yo@4.3.1

package.json

{
  "name": "test",
  "version": "0.0.0",
  "private": true,
  "author": "User <user@example.com>",
  "description": "A simple helpful robot for your Company",
  "dependencies": {
    "hubot": "3.5.0",
    "hubot-diagnostics": "^1.2.0",
    "hubot-google-images": "^0.2.7",
    "hubot-google-translate": "^0.2.1",
    "hubot-help": "^2.1.1",
    "hubot-heroku-keepalive": "^1.0.3",
    "hubot-maps": "^0.0.3",
    "hubot-pugme": "^0.1.1",
    "hubot-redis-brain": "^2.0.0",
    "hubot-rules": "^1.0.0",
    "hubot-scripts": "^2.17.2",
    "hubot-shipit": "^0.2.1",
    "hubot-slack": "^4.10.0"
  },
  "engines": {
    "node": "20.x"
  }
}

external-scripts.json

[
  "hubot-diagnostics",
  "hubot-help",
  "hubot-slack",
  "hubot-google-images",
  "hubot-google-translate",
  "hubot-pugme",
  "hubot-maps",
  "hubot-redis-brain",
  "hubot-rules",
  "hubot-shipit"
]

And after running: HUBOT_SLACK_TOKEN=xoxb-123-xyzn ./bin/hubot --adapter slack

Run `npm audit` for details.
[Thu Sep 07 2023 17:31:40 GMT+0000 (Coordinated Universal Time)] ERROR Cannot load adapter slack - /home/hubot/cleverbot/node_modules/hubot-slack/src/bot.coffee:22:10: error: unexpected newline
    super
         ^

Not sure what i am missing but i can't make it work. Any help would be appreciated.

joeyguerra commented 9 months ago

@evercast-mahesh2021, that error is because it's not running the script through coffee script.

I got a successful startup with these steps:

  1. given what you provided for package.json and external-scripts
  2. npm i coffeescript@1.11.1 <- Install coffeescript module within your app, as opposed to relying on the globally installed version
  3. add the following to the package.json file:
  "scripts": {
      "start": "hubot --adapter slack"
    }
  1. Run HUBOT_SLACK_TOKEN=xoxb-123-xyzn npm start
➜  myhubot git:(main) ✗ node --version
v20.6.0
evercast-mahesh2021 commented 9 months ago

Hi @joeyguerra thank you so much for the help. I got passed this issue but facing another one. Any idea? It is complaining about hubot module. Thanks

Hubot> [Mon Sep 11 2023 15:01:20 GMT+0000 (Coordinated Universal Time)] ERROR Error loading scripts from npm package - TypeError: require(...) is not a function
  at /usr/local/lib/node_modules/hubot/src/robot.js:409:52
  at Array.forEach (<anonymous>:null:null)
  at Robot.loadExternalScripts (/usr/local/lib/node_modules/hubot/src/robot.js:409:25)
  at /usr/local/lib/node_modules/hubot/bin/hubot.js:203:13
  at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read/context:68:3)
joeyguerra commented 9 months ago

@evercast-mahesh2021 delete "hubot-slack", from external-scripts.json.

evercast-mahesh2021 commented 9 months ago

@evercast-mahesh2021 delete "hubot-slack", from external-scripts.json.

Oh, awesome. It worked. Thanks for all the help.

leonardoivt commented 9 months ago

HI guys, has anyone managed to find any other solution? I followed all the previous steps with the same versions that were mentioned but I still have the same problem ERROR Cannot load adapter slack - /home/hubot/node_modules/hubot-slack/src/bot.coffee:22:10: error: unexpected newline

joeyguerra commented 9 months ago

@leonardoivt I believe that error is from not having coffeescript installed. Post the results of npm list -g, your package.json file and command your executing so we can put another pair of eyes on it.

leonardoivt commented 8 months ago

hey @joeyguerra thanks for reply, sorry for taking so long to respond, I managed to solve the problem using the dependencie versions stipulated in this thread; hubot : 3.5.0 coffeescript : 1.11.1