Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list index out of range #240

Closed
2 of 6 tasks
johnsturgeon opened this issue Jul 6, 2016 · 13 comments
Closed
2 of 6 tasks

IndexError: list index out of range #240

johnsturgeon opened this issue Jul 6, 2016 · 13 comments
Labels
Milestone

Comments

@johnsturgeon
Copy link

johnsturgeon commented Jul 6, 2016

Error:

(lldb) run
Traceback (most recent call last):
  File "/tmp/3B6FED61-05C1-4F71-8E19-CA4A084D3568/fruitstrap_4de9411f15a0f3881f8703357fa16272abf77758.py", line 36, in run_command
    lldb.target.Launch(lldb.SBLaunchInfo(shlex.split(args[1] and args[1] or '')), error)
IndexError: list index out of range

Expected behavior

launch and connect

Actual behavior.

see error above

Steps to reproduce the problem

ios-deploy --debug --bundle

System Specs

Please run the commands below in your Terminal.app and include it in the issue. Check when done and include results below.

  • 1. sw_vers -productVersion
$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.11.5
BuildVersion:   15F15
  • 2. ios-deploy -V
$ ios-deploy -V
2.0.0

the rest is under NDA

  • 3. xcodebuild -version
  • 4. xcode-select --print-path (can't show
  • 5. gcc --version
  • 6. lldb --version
@shazron shazron added this to the 2.0.0 milestone Aug 9, 2016
@shazron shazron added the bug label Aug 9, 2016
@gusc
Copy link

gusc commented Sep 7, 2016

Had this problem running ios-deploy 1.8.6 with iOS 10. Fixed it with this patch:

ios-deploy-1.8.6-ios10.diff.zip

@thiago-slb
Copy link

thiago-slb commented Sep 9, 2016

@gusc how did you applied this patch? Could you please explain it to me? I'm having the same error on macOS Sierra

@EeKay
Copy link

EeKay commented Sep 12, 2016

@gusc it seems this is a file containing the code changes. you can apply them by changing the file yourself. This code change might be applied to this git repo soon (i hope).
TL;DR:

  1. Go to your ios-deploy install location, probably:
  2. open the file /src/scripts/lldb.py
  3. remove the line in that file that equals the line in this zip file with the - prefix
  4. add the 4 lines in the file with the + prefix on the same location that you removed the one from step 3.

Long version:
Find your iso-deploy location as following:

  1. open your terminal and execute:
    type -P ios-deploy
  2. this points to the location where a smart link is created to run iso-deploy on your machine. Go to that location in your finder and right click it and select "Show Original"
  3. Your in the release dir where the exec is, go up in the tree to the "lib" dir and then select "ios-deploy" and then "src" and "scripts"
  4. open lldb.py in your favourite text editor
  5. goto line 35 and replace it with:

if len(args) > 1:
args_arr = shlex.split(args[1] and args[1] or '{args}')
lldb.target.Launch(lldb.SBLaunchInfo(args_arr), error)

it didn't fix my stuff (yet) though.. so still checking this out too

@gusc
Copy link

gusc commented Sep 12, 2016

It's easier than that:

  1. cd into source root
  2. run patch -p1 < ios-deploy-1.8.6-ios10.diff

Edit:

To see if the patch was applied correctly type git diff - that should show you almost the same output as cat ios-deploy-1.8.6-io10.diff

@shazron shazron mentioned this issue Sep 14, 2016
shazron added a commit that referenced this issue Sep 14, 2016
@shazron
Copy link

shazron commented Sep 14, 2016

Thanks @gusc - published 1.8.7 https://github.com/phonegap/ios-deploy/releases/tag/1.8.7

@dot-asm
Copy link

dot-asm commented Sep 14, 2016

While fixing the crash this modification made it impossible to pass command line arguments to ios application. The lldb.py should read

    if len(args) > 1:
        args_arr = shlex.split(args[1])
    else:
        args_arr = shlex.split('{args}')

instead of

    if len(args) > 1:
        args_arr = shlex.split(args[1] and args[1] or '{args}')

@shazron
Copy link

shazron commented Sep 14, 2016

@gusc can you comment on the above?

@dot-asm
Copy link

dot-asm commented Sep 15, 2016

I'd like to point out that original args[1] and args[1] or '{args}' actually reads as "if args[1] exists, then pass it, otherwise pass '{args}'". Another way to see if args[1] exists is of course to see if len(args) is larger than 1. In other words after addition of explicit if first condition in original args[1] and args[1] or '{args}' is always true and as result expression is always evaluated to args[1] and never to '{args}'. So that suggested modification simply brings back the "otherwise" clause in the original conditional statement.

Well, to be honest the args handling is a bit messy in sense that one mixes indexed and non-indexed references. So that it might be appropriate to replace '{args}' with args[0] to make things clearer...

@dot-asm
Copy link

dot-asm commented Sep 15, 2016

Oh! Forget that last "to be honest" remark! Despite same name '{args}' has nothing to do with args[] in the expression in question. Sorry about confusion....

@gusc
Copy link

gusc commented Sep 15, 2016

@shazron I just tried to make as small as possible fix for an issue when args is empty or None - I can't comment on the original syntax though - it looks a little bit weird as it would be enough to write args[1] or '{args}' (without the args[1] and). I'd actually go with the @dot-asm if/else solution than the messy boolean one.

@shazron
Copy link

shazron commented Sep 15, 2016

Alright, I'll file a new issue and put in @dot-asm's fix. I'll roll that in with the tvOS support pull request for 1.8.8

I agree, I'd rather the code be more explicit than clever :)

@shazron
Copy link

shazron commented Sep 16, 2016

1.9.0 published: https://github.com/phonegap/ios-deploy/releases/tag/1.9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants