busted icon indicating copy to clipboard operation
busted copied to clipboard

busted doesn't work, busted_bootstrap does

Open ostinelli opened this issue 10 years ago • 25 comments

Hello, After installing the latest 2.0.rc3 I wanted to go back to the stable 1.11.1. So I did, and this is what I have installed:

$ luarocks list

Installed rocks:
----------------
...
busted
   1.11.1-1 (installed) - /usr/local/lib/luarocks/rocks
...

When I run busted I get:

$ busted
luajit: /usr/local/bin/busted_bootstrap:3: unexpected symbol near '-'

When I run busted_bootstrap I get:

$ busted_bootstrap 

●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●● ○
195 successes / 0 failures / 0 pending : 0.141569 seconds.

The file busted_bootstrap contains:

#!/bin/sh

exec '/usr/local/opt/lua/bin/lua5.2' -e 'package.path="/Users/roberto/.luarocks/share/lua/5.2/?.lua;/Users/roberto/.luarocks/share/lua/5.2/?/init.lua;/usr/local/share/lua/5.2/?.lua;/usr/local/share/lua/5.2/?/init.lua;"..package.path; package.cpath="/Users/roberto/.luarocks/lib/lua/5.2/?.so;/usr/local/lib/lua/5.2/?.so;"..package.cpath' -e 'local k,l,_=pcall(require,"luarocks.loader") _=k and l.add_context("busted","1.11.1-1")' '/usr/local/lib/luarocks/rocks/busted/1.11.1-1/bin/busted_bootstrap' "$@"

My system:

$ lua -v
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
$ luajit -v
LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/

Any ideas?

Thank you, r.

ostinelli avatar Oct 30 '14 18:10 ostinelli

You may need to force-uninstall the rc before the stable version is usable; things changed around with the bin files, and I'm guessing they didn't get cleaned up.

ajacksified avatar Oct 30 '14 18:10 ajacksified

Unfortunately this doesn't fix it.

robertos-MacBook-Pro:  ~/workspace/gin  | master ✗ |
$ luarocks remove --force busted
Checking stability of dependencies on the absence of
busted 1.11.1-1...

The following packages may be broken by this forced removal:
gin 0.1.4-1

Removing busted 1.11.1-1...
Missing dependency for gin 0.1.4-1: busted == 1.11.1
Removal successful.

robertos-MacBook-Pro:  ~/workspace/gin  | master ✗ |
$ luarocks install busted 1.11.1-1
Warning: falling back to curl - install luasec to get native HTTPS support
Installing https://rocks.moonscript.org/busted-1.11.1-1.src.rock...
Using https://rocks.moonscript.org/busted-1.11.1-1.src.rock... switching to 'build' mode
Updating manifest for /usr/local/lib/luarocks/rocks
busted 1.11.1-1 is now built and installed in /usr/local (license: MIT <http://opensource.org/licenses/MIT>)


robertos-MacBook-Pro:  ~/workspace/gin  | master ✗ |
$ busted
luajit: /usr/local/bin/busted_bootstrap:3: unexpected symbol near '-'

Anything I can try?

Best, r.

ostinelli avatar Oct 30 '14 18:10 ostinelli

I had the same issue and needed to remove 2.0.rc3 using "iron fist"

  • find /usr -name luarocks yields /usr/local/lib/luarocks
  • rm -rf /usr/local/lib/luarocks/rocks/busted/
  • vim /usr/local/lib/luarocks/rocks/manifest
  • remove all "busted" entries manually
  • reinstall luarocks install busted 1.11.1

istr avatar Nov 06 '14 10:11 istr

This doesn't fix it for me. It's really annoying.

ostinelli avatar Nov 06 '14 17:11 ostinelli

:-( From your commandline I conclude that you are running OS X? The brute-force method above worked on a linux machine... Maybe things (luarocks libraries) are organized differently under OS X.

istr avatar Nov 06 '14 18:11 istr

I've already manually removed anything I could find of busted from my system. I don't have anything else to try until I get hopefully some fix :)

ostinelli avatar Nov 06 '14 18:11 ostinelli

Inspecting your initial post further it seems that the stuff under /usr/local/bin is messed up. Maybe the scripts under /usr/local/bin/ were not replaced properly due to access rights and/or symlink issues?

My setup says:

  • /usr/local/bin/busted is a shell script
  • /usr/local/bin/busted_bootstrap is a lua file

Your post says:

  • /usr/local/bin/busted is a shell script that tries to run /usr/local/bin/busted_bootstrap using luajit
  • /usr/local/bin/busted_bootstrap is a shell script (that naturally could not be executed by luajit)

This is my setup after a fresh (and working) install of busted 1.11.1: $ which busted /usr/local/bin/busted

$ cat /usr/local/bin/busted
#!/bin/sh
commandExists () {
    command -v "$1" > /dev/null
}

# Obtain $COMMAND
while getopts ":l:" optchar; do
  case $optchar in
    l)
      COMMAND="$OPTARG"
      ;;
    :)
      echo "Option -$OPTARG requires an argument." >&2
      exit 1
      ;;
  esac
done

if commandExists $COMMAND ; then
  COMMAND=$COMMAND;
elif commandExists $LUA ; then
  COMMAND=$LUA;
elif commandExists luajit ; then
  COMMAND=luajit;
elif commandExists lua ; then
  COMMAND=lua;
else
  echo >&2 "Busted requires that a valid execution environment be specified(or that you have lua or luajit accessible in your PATH). Aborting.";
  exit 1
fi

# Obtain $BOOSTRAP_PATH
DIR="$( dirname "$0" )"
BOOTSTRAP_PATH="$DIR/busted_bootstrap"

if commandExists cygpath ; then
  BOOTSTRAP_PATH=`cygpath -ms "${BOOTSTRAP_PATH}"`
fi

# Execution
$COMMAND $BOOTSTRAP_PATH $*
$ head -n 20 /usr/local/bin/busted_bootstrap 
-- Busted command-line runner

local cli = require 'cliargs'
local utils = require 'pl.utils'
local path = require 'pl.path'
local tablex = require 'pl.tablex'
local busted = require 'busted'

local defaultoutput = busted.defaultoutput
local defaultpattern = busted.defaultpattern
local defaultlua = busted.defaultlua
local lpathprefix = busted.lpathprefix
local cpathprefix = busted.cpathprefix
local ansicolors = require "ansicolors"

cli:set_name("busted")
cli:add_flag("--version", "prints the program's version and exits")

cli:optarg("ROOT", "test script file/folder. Folders will be traversed for any file that matches the --pattern option.", "spec", 1)

I hope that helps...

istr avatar Nov 06 '14 18:11 istr

Same problem for me :(

lipp avatar Nov 10 '14 13:11 lipp

this workaround helps:

edit last line in /usr/local/bin/busted (which busted) from: $COMMAND $BOOTSTRAP_PATH $* to: $BOOTSTRAP_PATH $*

But: Is this a busted/luarocks/homebrew issue?

lipp avatar Nov 12 '14 19:11 lipp

I have the same problem and followed @lipp and it works now.

Ubuntu 14.10 amd64, busted 1.11.1.

I did notice that Busted v1.11.0 works.

rjpcomputing avatar Nov 21 '14 20:11 rjpcomputing

Same problem here, Mac Book with luarocks installed from homebrew. Applying @lipp's fix did not work (The command busted . gets hung up and never finishes)

EDIT: I ended up just deleting busted and renaming busted_bootstrap to busted. That's the only thing that seems to work.

kikito avatar Nov 23 '14 18:11 kikito

@lipp fix works for me too. Thank you!

ostinelli avatar Dec 23 '14 22:12 ostinelli

Closing this since it only affects the rcs and changes between old busted and new.

DorianGray avatar Feb 27 '15 22:02 DorianGray

@lipp fix works for me too (linux; luarocks compiled from source). Thanks.

istr avatar Mar 02 '15 09:03 istr

@DorianGray What's the suggested workaround for this issue?

The problem appears to be that /usr/local/bin/busted_bootstrap is a shell script, and does appear to come from version 2, but gets installed for busted 1.11.1, too.

/usr/local/lib/luarocks/rocks/busted/1.11.1-2/bin/busted_bootstrap seems to be OK, but why isn't this file installed into /usr/local/bin/busted_bootstrap?

blueyed avatar Jun 10 '15 17:06 blueyed

Uninstalling busted removes the /usr/local/bin/busted_bootstrap file, but when installing 1.11.1, the wrong version is getting installed there.

blueyed avatar Jun 10 '15 17:06 blueyed

And it does not appear to be related to having installed version 2 previously (see https://travis-ci.org/blueyed/awesome/builds/66254287).

blueyed avatar Jun 10 '15 17:06 blueyed

It seems to be related to luarocks creating a wrapper for/to /usr/local/lib/luarocks/rocks/busted/1.11.1-2/bin/busted_bootstrap after all.

blueyed avatar Jun 10 '15 17:06 blueyed

busted-1.11.1-2.rockspec has this, while version 2 only has the first entry:

 install = {
    bin = {
      ["busted"] = "bin/busted",
      ["busted.bat"] = "bin/busted.bat",
      ["busted_bootstrap"] = "bin/busted_bootstrap"
    }
  }

blueyed avatar Jun 10 '15 17:06 blueyed

Yes, for v 2.0 we changed how the test runner is loaded fairly drastically.

After reading this thread again, I think there are a few issues being conflated. Also, I cannot reproduce the issue on linux. I think tracking this one down may be up to you! If you do figure it out, please make a pull request so we can make a few more people happy.

DorianGray avatar Jun 10 '15 18:06 DorianGray

@DorianGray The linked build is a Linux machine (Travis). I could imagine that some luarocks update / setting is involved here, which creates the wrapper around busted_bootstrap. Maybe that could be disabled?

blueyed avatar Jun 10 '15 18:06 blueyed

I can replicate this issue with latest luarocks and busted-1.11.1 official rock reliably on linux. Even after completely fresh luarocks setup. Invariably @lipp s fix https://github.com/Olivine-Labs/busted/issues/290#issuecomment-62779977 resolves the issue after installing busted using the official luarock. Verified for lua 5.1 and lua 5.2 on Ubuntu 14.04.2 LTS machine with vanilla luarocks 2.2.2 built from sources.

istr avatar Jun 10 '15 18:06 istr

I think that I nailed down this problem: the busted rockspec does not comply with what luarocks expects: https://github.com/keplerproject/luarocks/wiki/Rockspec-format see "build.install": build.install.bin (table) - Lua command-line scripts. bin/busted in 0e88edb9fb20c4446d194a15fa13bfbf9041c16f (1.11.1) is NOT a lua command line script, thus violates the rockspec format and this is why it fails (the "double" wrapping is a fault on the busted rockspec side, not on the luarocks side). Will make a PR for that soon. Just need to fix the rockspec (only include the lua script) and rename bin/busted_bootstrap to bin/busted for 1.11.1 I guess.

istr avatar Jun 10 '15 18:06 istr

@istr Makes sense. Thanks!

blueyed avatar Jun 10 '15 19:06 blueyed

To solve this problem on Ubuntu 15.04, I ran: luarocks remove busted --force sudo luarocks install busted

alexspetty avatar Mar 06 '16 22:03 alexspetty