ricobeck / KFCocoaPodsPlugin

XcodePlugin for CocoaPods with pod commands/console output, user notifications & code completion.
http://kfi-apps.com/plugins/kfcocoapodsplugin/
800 stars 53 forks source link

"Run Update/Install" #2

Closed carlosefonseca closed 11 years ago

carlosefonseca commented 11 years ago

When I do "Run Update/Install", this is the output on the console…

start pod update Cocoapods update failed Cocoapods update succeeded

Kinda weird that failed and succeeded… Also, is this command suppose to do the "pod install"?

ricobeck commented 11 years ago

If no Podfile.lock exists in the workspace it runs 'pod install' else it does a 'pod update'. The output in the console was wrong – there was a return missing. Thanks for pointing that out.

carlosefonseca commented 11 years ago

That commit didn't resolve this issue :( It acted the same… I even removed the .xcplugin just to be sure but nothing…

kreeger commented 11 years ago

Yep, I'm still getting this behavior, too.

gabrielrinaldi commented 11 years ago

+1

ricobeck commented 11 years ago

does this happen with every podfile or only on specific projects? i need some more information because i connot reproduce this on three machines i've tested so far. can anyone please log the exception in https://github.com/ricobeck/KFCocoaPodsPlugin/blob/master/KFCocoaPodsPlugin/KFCocoaPodsPlugin.m#L343 ?

fleshgolem commented 11 years ago

Can confirm this error, seems to happen on every project

Exception description is "launch path not accessible

Stack trace:

0   CoreFoundation                      0x00007fff8f030b06 __exceptionPreprocess + 198
1   DVTFoundation                       0x0000000108616c23 DVTFailureHintExceptionPreprocessor + 194
2   libobjc.A.dylib                     0x00007fff8cc613f0 objc_exception_throw + 43
3   CoreFoundation                      0x00007fff8f0308dc +[NSException raise:format:] + 204
4   Foundation                          0x00007fff8d5f8c22 -[NSConcreteTask launchWithDictionary:] + 409
5   KFCocoaPodsPlugin                   0x000000010f8a899f -[KFTaskController runShellCommand:withArguments:directory:progress:completion:] + 1503
6   KFCocoaPodsPlugin                   0x000000010f8a4131 __37-[KFCocoaPodsPlugin podUpdateAction:]_block_invoke + 1009
7   libdispatch.dylib                   0x00007fff90f9ff01 _dispatch_call_block_and_release + 15
8   libdispatch.dylib                   0x00007fff90f9c0b6 _dispatch_client_callout + 8
9   libdispatch.dylib                   0x00007fff90f9d1fa _dispatch_worker_thread2 + 304
10  libsystem_c.dylib                   0x00007fff8eb47d0b _pthread_wqthread + 404
11  libsystem_c.dylib                   0x00007fff8eb321d1 start_wqthread + 13

If you need anything else let me know, and give me a hint on how to properly debug plugins, because I have no idea :)

ricobeck commented 11 years ago

What version of CocoaPods is installed (type 'pod --version' in the terminal)? Which OSX Version?

kreeger commented 11 years ago

I'm running CocoaPods 0.24.0… same exception as reported as @fleshgolem. For what it's worth, I've got CocoaPods installed under my instance of Ruby 2.0.0-p247 (installed via rbenv, set as system ruby). I was getting this error running on a copy of KFCocoaPodsPlugin, even (I see the error on every project).

ricobeck commented 11 years ago

What says 'which pod' in the terminal? I think it is not in the launch path that i assume (that was on machines i tested with alway '/usr/bin/pod').

kreeger commented 11 years ago

I ran it down and it's because of line 69. My pod executable is in the folder generated by my rbenv instance, which is…

$HOME/.rbenv/shims/pod

You'll need to find some way of finding the user's pod command (perhaps based on their shell's environment settings) because not everyone is going to have pod in /usr/bin/pod. After I swapped in the location for my pod command, it worked as expected.

ricobeck commented 11 years ago

Thank you very much for investigating this! I have an idea how to resolve this ...

ricobeck commented 11 years ago

Does it work with the version in this branch? (For me it does.) https://github.com/ricobeck/KFCocoaPodsPlugin/tree/feature/detect-pod-path

kreeger commented 11 years ago

Doesn't work for me — I tried putting in some logging statements around your additions to inspect the output, but they never get run.

ricobeck commented 11 years ago

Oh sorry, it's a bit late - i forgot to use the detected path and took still the old static. Could you please test again?

fleshgolem commented 11 years ago

That did not work either.

The Problem is that execution through rbenv is dependent on the user's path settings which are in turn dependent on the user's shell (zsh for me), both of which NSTask actually can't really handle

I tried a few different options, but none of them worked so just gave up and did sudo ln -s ~/.rbenv/shims/pod /usr/bin/pod and it's propably easiest to pass on that advice to other users

If you want to fight with it yourself, there is some info here: http://stackoverflow.com/questions/17340569/nstask-launch-path-not-accessible-works-in-xcode-error-shown-out-of-xcode

fleshgolem commented 11 years ago

As an aside that is not really worth its own issue:

This bit:

@finally
    {
        completionBlock(task, YES, [[NSString alloc] initWithData:outputData encoding:NSUTF8StringEncoding], nil);
    }

Causes all failed tasks to report success as well, which is pretty confusing (see OP)

ricobeck commented 11 years ago

Currently i am trying to change to DSUnixTask. The features sound promising (e.g. 'Execute throughout the user shell.')

ricobeck commented 11 years ago

My changes are done, could you please test if this can fix the problem?

(When a task was executed you should restart Xcode – there is a bug in DSUnixTask. I fixed this for me locally and will make a pull request later.)

fleshgolem commented 11 years ago

Yeah, that works. Thank you

ricobeck commented 11 years ago

Ah, good news. :) I'll wait until tomorrow then i'll merge this into master. Would be good if any of the other participants could confirm that it's working now.

carlosefonseca commented 11 years ago

It's the feature/detect-pod-path branch?

Checked it out, installed it ran it and got

Start pod update Cocoapods update failed

$ which pod /Users/carlos/.rvm/gems/ruby-2.0.0-p0/bin/pod

fleshgolem commented 11 years ago

TBH, i had a problem, where my rbenv path was added in .zprofile instead of a more appropriate spot as .zshenv

I.e. the path would only be set for login shells, which is of no use for external applications and there really is no way to work around that other than correct your setup

@carlosefonseca: Do you know where you do add that path? I don't really know how rvm handles its paths, because I only use rbenv

carlosefonseca commented 11 years ago

My .bash_profile sources ~/.rvm/scripts/rvm. If I remove that, I have no pod

fleshgolem commented 11 years ago

Put that in your .bashrc instead (or as well) and it should work. bash_profile only gets loaded on login shells (i.e. shells running in a terminal emulator mostly)

carlosefonseca commented 11 years ago

Yup, that did it :)

fleshgolem commented 11 years ago

That's pretty dumb of rvm, to put their path configuration there tbh and i guess there is really not much you can do about it, other than telling users to fix their path configuration

carlosefonseca commented 11 years ago

ops