每次启动终端时都会出现权限被拒绝的消息

每次启动终端时都会出现权限被拒绝的消息

每次启动终端时都会收到此错误消息:

-bash:/Users/myusername/.profile:权限被拒绝

但我仍然可以照常使用终端。

这可能是在我安装了使用终端的某些东西之后出现的。
似乎有一些东西正在尝试访问.profile不存在的东西。
请注意.bash_profile存在。

我运行了以下命令:

grep -n profile ~/.* 2>/dev/null

得到了这个结果:

/Users/myusername/.v8flags.3.14.5.9.myusername.json:1:["--use_strict","--es5_readonly","--es52_globals","--harmony_typeof","--harmony_scoping","--harmony_modules","--harmony_proxies","--harmony_collections","--harmony","--packed_arrays","--smi_only_arrays","--clever_optimizations","--unbox_double_arrays","--string_slices","--crankshaft","--hydrogen_filter","--use_range","--eliminate_dead_phis","--use_gvn","--use_canonicalizing","--use_inlining","--max_inlined_source_size","--max_inlined_nodes","--max_inlined_nodes_cumulative","--loop_invariant_code_motion","--collect_megamorphic_maps_from_stub_cache","--hydrogen_stats","--trace_hydrogen","--trace_phase","--trace_inlining","--trace_alloc","--trace_all_uses","--trace_range","--trace_gvn","--trace_representation","--stress_pointer_maps","--stress_environments","--deopt_every_n_times","--trap_on_deopt","--deoptimize_uncommon_cases","--polymorphic_inlining","--use_osr","--array_bounds_checks_elimination","--array_index_dehoisting","--dead_code_elimination","--trace_dead_code_elimination","--trace_osr","--stress_runs","--optimize_closures","--lookup_sample_by_shared","--cache_optimized_code","--inline_construct","--inline_arguments","--inline_accessors","--loop_weight","--optimize_for_in","--opt_safe_uint32_operations","--parallel_recompilation","--trace_parallel_recompilation","--parallel_recompilation_queue_length","--experimental_profiler","--watch_ic_patching","--frame_count","--self_optimization","--direct_self_opt","--retry_self_opt","--count_based_interrupts","--interrupt_at_exit","--weighted_back_edges","--interrupt_budget","--type_info_threshold","--self_opt_count","--trace_opt_verbose","--debug_code","--code_comments","--enable_sse2","--enable_sse3","--enable_sse4_1","--enable_cmov","--enable_rdtsc","--enable_sahf","--enable_vfp3","--enable_vfp2","--enable_armv7","--enable_sudiv","--enable_movw_movt","--enable_unaligned_accesses","--enable_fpu","--expose_natives_as","--expose_debug_as","--expose_gc","--expose_externalize_string","--stack_trace_limit","--builtins_in_stack_traces","--disable_native_files","--inline_new","--stack_trace_on_abort","--trace","--mask_constants_with_cookie","--lazy","--trace_opt","--trace_opt_stats","--opt","--always_opt","--prepare_always_opt","--trace_deopt","--min_preparse_length","--always_full_compiler","--max_opt_count","--compilation_cache","--cache_prototype_transitions","--trace_debug_json","--debugger_auto_break","--enable_liveedit","--break_on_abort","--stack_size","--max_stack_trace_source_length","--always_inline_smi_code","--max_new_space_size","--max_old_space_size","--max_executable_size","--gc_global","--gc_interval","--trace_gc","--trace_gc_nvp","--trace_gc_ignore_scavenger","--print_cumulative_gc_stat","--trace_gc_verbose","--trace_fragmentation","--trace_external_memory","--collect_maps","--flush_code","--incremental_marking","--incremental_marking_steps","--trace_incremental_marking","--track_gc_object_stats","--use_idle_notification","--use_ic","--native_code_counters","--always_compact","--lazy_sweeping","--never_compact","--compact_code_space","--incremental_code_compaction","--cleanup_code_caches_at_gc","--random_seed","--use_verbose_printer","--allow_natives_syntax","--trace_parse","--trace_sim","--check_icache","--stop_sim_at","--sim_stack_alignment","--abort_on_uncaught_exception","--trace_exception","--preallocate_message_memory","--randomize_hashes","--hash_seed","--preemption","--regexp_optimization","--testing_bool_flag","--testing_int_flag","--testing_float_flag","--testing_string_flag","--testing_prng_seed","--testing_serialization_file","--extra_code","--dump_counters","--debugger","--remote_debugger","--debugger_agent","--debugger_port","--map_counters","--js_arguments","--debug_compile_events","--debug_script_collected_events","--gdbjit","--gdbjit_full","--gdbjit_dump","--gdbjit_dump_filter","--force_marking_deque_overflows","--stress_compaction","--log","--log_all","--log_runtime","--log_api","--log_code","--log_gc","--log_handles","--log_snapshot_positions","--log_suspect","--prof","--prof_auto","--prof_lazy","--prof_browser_mode","--log_regexp","--sliding_state_window","--logfile","--ll_prof","--gc_fake_mmap"]

我还在 /etc/profile 文件末尾添加了 set -x 并得到了以下结果:

Last login: Mon Oct  5 21:54:04 on ttys001
+ export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/bin
+ PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/bin
+ export PATH=/Applications/MAMP/bin/php/php5.5.10/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/bin
+ PATH=/Applications/MAMP/bin/php/php5.5.10/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/bin
+ /Users/myusername/.profile
-bash: /Users/myusername/.profile: Permission denied
+ [[ -s /Users/myusername/.rvm/scripts/rvm ]]
+ source /Users/myusername/.rvm/scripts/rvm
++ builtin test -n '3.2.53(1)-release' -o -n '' -o -n ''
++ case "`uname`" in
+++ uname
+++ command ps -p 14417 -o ucomm=
+++ ps -p 14417 -o ucomm=

对我来说,看起来应用程序 MAMP 导致了问题,对吗?

答案1

调查启动问题rc文件,您可以为每个命令生成跟踪,例如:

  1. 编辑/etc/profile(例如sudo vim /etc/profile)。
  2. 附加set -x到文件末尾。
  3. 打开新的终端窗口,它将显示跟踪输出。

通过跟踪输出,您可以轻松识别您的没有权限问题(通过+进行搜索f)。删除有问题的行后,删除set -x您附加的内容。

答案2

我找到了问题所在。我在 ~/.bash_profile 中有这样一行:

~/.profile

我删除了该行,问题解决了。

相关内容